#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ average(int);
int /*<<< orphan*/ usage(char *);
int main(int argc, char **argv) {
  int n = 100;
  switch (argc) {
  case 1:
    break;
  case 2:
    n = atoi(argv[1]);
    if (n <= 0)
      usage(*argv);
    break;
  default:
    usage(*argv);
  }
  average(n);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x64,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
sub    $0x1,%eax
je     1172 <main+0x42>
jmp    1161 <main+0x31>
mov    -0x18(%rbp),%eax
sub    $0x2,%eax
je     1177 <main+0x47>
jmp    11a2 <main+0x72>
jmp    11ae <main+0x7e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jg     119d <main+0x6d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <usage@plt>
jmp    11ae <main+0x7e>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <usage@plt>
mov    -0x14(%rbp),%edi
call   1030 <average@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x64,%ebx
cmp    $0x1,%edi
je     115d <main+0x2d>
mov    %rsi,%r14
cmp    $0x2,%edi
jne    1155 <main+0x25>
mov    0x8(%r14),%rdi
call   1050 <atoi@plt>
mov    %eax,%ebx
test   %eax,%eax
jg     115d <main+0x2d>
mov    (%r14),%rdi
call   1040 <usage@plt>
mov    %ebx,%edi
call   1030 <average@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 100, i32* %6
%7 = load i32, i32* %4
switch i32 %7, label %21 [
i32 1, label %8
i32 2, label %9
]
8: ; preds = %2
br label %25
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i32 @atoi(i8* %12)
store i32 %13, i32* %6
%14 = load i32, i32* %6
%15 = icmp sle i32 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %9
%17 = load i8**, i8*** %5
%18 = load i8*, i8** %17
%19 = call i32 @usage(i8* %18)
br label %20
20: ; preds = %16, %9
br label %25
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = load i8*, i8** %22
%24 = call i32 @usage(i8* %23)
br label %25
25: ; preds = %21, %20, %8
%26 = load i32, i32* %6
%27 = call i32 @average(i32 %26)
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture %1) {
switch i32 %0, label %8 [
i32 1, label %12
i32 2, label %3
]
3: ; preds = %2
%4 = getelementptr inbounds i8*, i8** %1, i64 1
%5 = load i8*, i8** %4
%6 = tail call i32 @atoi(i8* %5)
%7 = icmp slt i32 %6, 1
br i1 %7, label %8, label %12
8: ; preds = %2, %3
%9 = phi i32 [ %6, %3 ], [ 100, %2 ]
%10 = load i8*, i8** %1
%11 = tail call i32 @usage(i8* %10)
br label %12
12: ; preds = %8, %3, %2
%13 = phi i32 [ %6, %3 ], [ 100, %2 ], [ %9, %8 ]
%14 = tail call i32 @average(i32 %13)
ret i32 0
}