#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 /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  printf("Program name %s\n", argv[0]);
  if (argc == 2) {
    printf("The argument supplied is %s\n", argv[1]);
  } else if (argc > 2) {
    printf("Too many arguments supplied.\n");
  } else {
    printf("One argument expected.\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xecc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x2,-0x8(%rbp)
jne    1160 <main+0x50>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1190 <main+0x80>
cmpl   $0x2,-0x8(%rbp)
jle    117d <main+0x6d>
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    118b <main+0x7b>
lea    0xec8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1190 <main+0x80>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
mov    (%rsi),%rsi
lea    0xece(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x2,%ebp
jne    1152 <main+0x32>
mov    0x8(%rbx),%rsi
lea    0xec8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1169 <main+0x49>
jle    115d <main+0x3d>
lea    0xeea(%rip),%rdi
jmp    1164 <main+0x44>
lea    0xeca(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"Program name %s\0A\00"
@.str.1 = [29 x i8] c"The argument supplied is %s\0A\00"
@.str.2 = [30 x i8] c"Too many arguments supplied.\0A\00"
@.str.3 = [24 x i8] c"One argument expected.\0A\00"
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 i8**, i8*** %5
%7 = getelementptr inbounds i8*, i8** %6, i64 0
%8 = load i8*, i8** %7
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = load i32, i32* %4
%11 = icmp eq i32 %10, 2
br i1 %11, label %12, label %17
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %15)
br label %25
17: ; preds = %2
%18 = load i32, i32* %4
%19 = icmp sgt i32 %18, 2
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
br label %24
22: ; preds = %17
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
br label %24
24: ; preds = %22, %20
br label %25
25: ; preds = %24, %12
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"Program name %s\0A\00"
@.str.1 = [29 x i8] c"The argument supplied is %s\0A\00"
@str = [23 x i8] c"One argument expected.\00"
@str.4 = [29 x i8] c"Too many arguments supplied.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = load i8*, i8** %1
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %3)
%5 = icmp eq i32 %0, 2
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %8)
br label %16
10: ; preds = %2
%11 = icmp sgt i32 %0, 2
br i1 %11, label %12, label %14
12: ; preds = %10
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.4, i64 0, i64 0))
br label %16
14: ; preds = %10
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
br label %16
16: ; preds = %12, %14, %6
ret i32 0
}