#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*/ c89_fake_snprintf(char *, int, char *, int, char const *);
int /*<<< orphan*/ printf(char *, char *);
int main(int argc, char **argv) {
  int i;
  const char *s;
  char buf[80];
  i = (argc > 1) ? atoi(argv[1]) : 100;
  s = (argc > 2) ? argv[2] : "awesome";
  c89_fake_snprintf(buf, 80, "%d%% %s!", i, s);
  printf("%s\n", buf);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1168 <main+0x38>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x74(%rbp)
jmp    1175 <main+0x45>
mov    $0x64,%eax
mov    %eax,-0x74(%rbp)
jmp    1175 <main+0x45>
mov    -0x74(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    1196 <main+0x66>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x80(%rbp)
jmp    11a6 <main+0x76>
lea    0xe63(%rip),%rax
mov    %rax,-0x80(%rbp)
jmp    11a6 <main+0x76>
mov    -0x80(%rbp),%rax
mov    %rax,-0x20(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x14(%rbp),%ecx
mov    -0x20(%rbp),%r8
mov    $0x50,%esi
lea    0xe43(%rip),%rdx
call   1040 <c89_fake_snprintf@plt>
lea    -0x70(%rbp),%rsi
lea    0xe3c(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x50,%rsp
lea    0xec1(%rip),%r14
mov    $0x64,%ecx
cmp    $0x2,%edi
jl     1162 <main+0x32>
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x8(%rsi),%rdi
call   1050 <atoi@plt>
mov    %eax,%ecx
cmp    $0x2,%ebp
je     1162 <main+0x32>
mov    0x10(%rbx),%r14
lea    0xe9f(%rip),%rdx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x50,%esi
mov    %r14,%r8
call   1040 <c89_fake_snprintf@plt>
lea    0xe8e(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"awesome\00"
@.str.1 = [9 x i8] c"%d%% %s!\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca [80 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp sgt i32 %9, 1
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @atoi(i8* %14)
br label %17
16: ; preds = %2
br label %17
17: ; preds = %16, %11
%18 = phi i32 [ %15, %11 ], [ 100, %16 ]
store i32 %18, i32* %6
%19 = load i32, i32* %4
%20 = icmp sgt i32 %19, 2
br i1 %20, label %21, label %25
21: ; preds = %17
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 2
%24 = load i8*, i8** %23
br label %26
25: ; preds = %17
br label %26
26: ; preds = %25, %21
%27 = phi i8* [ %24, %21 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), %25 ]
store i8* %27, i8** %7
%28 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%29 = load i32, i32* %6
%30 = load i8*, i8** %7
%31 = call i32 @c89_fake_snprintf(i8* %28, i32 80, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %29, i8* %30)
%32 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%33 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %32)
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"awesome\00"
@.str.1 = [9 x i8] c"%d%% %s!\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [80 x i8]
%4 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %14
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @atoi(i8* %8)
%10 = icmp eq i32 %0, 2
br i1 %10, label %14, label %11
11: ; preds = %6
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
br label %14
14: ; preds = %2, %6, %11
%15 = phi i32 [ %9, %11 ], [ %9, %6 ], [ 100, %2 ]
%16 = phi i8* [ %13, %11 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), %6 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), %2 ]
%17 = call i32 @c89_fake_snprintf(i8* %4, i32 80, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %15, i8* %16)
%18 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %4)
ret i32 0
}