#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 usage(char *);
int work(char *, char *, char *, int);
int main(int argc, char **argv) {
  switch (argc) {
  case 3:
    return work(argv[0], argv[1], argv[2], 8192);
  case 4:
    return work(argv[0], argv[1], argv[2], atoi(argv[3]));
  default:
    return usage(argv[0]);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
sub    $0x3,%eax
je     116b <main+0x3b>
jmp    115a <main+0x2a>
mov    -0x14(%rbp),%eax
sub    $0x4,%eax
je     1194 <main+0x64>
jmp    11df <main+0xaf>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
mov    $0x2000,%ecx
call   1030 <work@plt>
mov    %eax,-0x4(%rbp)
jmp    11ee <main+0xbe>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1050 <atoi@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    %eax,%ecx
call   1030 <work@plt>
mov    %eax,-0x4(%rbp)
jmp    11ee <main+0xbe>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <usage@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
cmp    $0x4,%edi
je     1154 <main+0x24>
cmp    $0x3,%edi
jne    117d <main+0x4d>
mov    (%rsi),%rdi
mov    0x8(%rsi),%rax
mov    0x10(%rsi),%rdx
mov    %rax,%rsi
mov    $0x2000,%ecx
jmp    1173 <main+0x43>
mov    (%rsi),%rbx
mov    0x8(%rsi),%r14
mov    0x10(%rsi),%r15
mov    0x18(%rsi),%rdi
call   1050 <atoi@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %eax,%ecx
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <work@plt>
mov    (%rsi),%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <usage@plt>

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
switch i32 %6, label %33 [
i32 3, label %7
i32 4, label %18
]
7: ; preds = %2
%8 = load i8**, i8*** %5
%9 = getelementptr inbounds i8*, i8** %8, i64 0
%10 = load i8*, i8** %9
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 2
%16 = load i8*, i8** %15
%17 = call i32 @work(i8* %10, i8* %13, i8* %16, i32 8192)
store i32 %17, i32* %3
br label %38
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 0
%21 = load i8*, i8** %20
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 2
%27 = load i8*, i8** %26
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 3
%30 = load i8*, i8** %29
%31 = call i32 @atoi(i8* %30)
%32 = call i32 @work(i8* %21, i8* %24, i8* %27, i32 %31)
store i32 %32, i32* %3
br label %38
33: ; preds = %2
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 0
%36 = load i8*, i8** %35
%37 = call i32 @usage(i8* %36)
store i32 %37, i32* %3
br label %38
38: ; preds = %33, %18, %7
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture %1) {
switch i32 %0, label %20 [
i32 3, label %3
i32 4, label %10
]
3: ; preds = %2
%4 = load i8*, i8** %1
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = getelementptr inbounds i8*, i8** %1, i64 2
%8 = load i8*, i8** %7
%9 = tail call i32 @work(i8* %4, i8* %6, i8* %8, i32 8192)
br label %23
10: ; preds = %2
%11 = load i8*, i8** %1
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = getelementptr inbounds i8*, i8** %1, i64 2
%15 = load i8*, i8** %14
%16 = getelementptr inbounds i8*, i8** %1, i64 3
%17 = load i8*, i8** %16
%18 = tail call i32 @atoi(i8* %17)
%19 = tail call i32 @work(i8* %11, i8* %13, i8* %15, i32 %18)
br label %23
20: ; preds = %2
%21 = load i8*, i8** %1
%22 = tail call i32 @usage(i8* %21)
br label %23
23: ; preds = %20, %10, %3
%24 = phi i32 [ %22, %20 ], [ %19, %10 ], [ %9, %3 ]
ret i32 %24
}