#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*/ execlp(char *, char *, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ increment_rank();
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ whoami(char *);
int main(int argc, char **argv) {
  increment_rank();
  whoami("baz");
  int nb = atoi(argv[1]);
  nb--;
  char buffer[20];
  sprintf(buffer, "%d", nb);
  execlp("foo", "foo", buffer, NULL);
  return 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    $0x0,%al
call   1040 <increment_rank@plt>
lea    0xe8c(%rip),%rdi
call   1030 <whoami@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xe64(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x30(%rbp),%rdx
lea    0xe57(%rip),%rsi
xor    %eax,%eax
mov    %eax,%ecx
mov    %rsi,%rdi
call   1070 <execlp@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%rbx
xor    %eax,%eax
call   1040 <increment_rank@plt>
lea    0xe9a(%rip),%rdi
call   1030 <whoami@plt>
mov    0x8(%rbx),%rdi
call   1050 <atoi@plt>
lea    -0x1(%rax),%edx
lea    0xe86(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1060 <sprintf@plt>
lea    0xe77(%rip),%rdi
mov    %rdi,%rsi
mov    %rbx,%rdx
xor    %ecx,%ecx
call   1070 <execlp@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"baz\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c"foo\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [20 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 (...) @increment_rank()
%9 = call i32 @whoami(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%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 = add nsw i32 %14, -1
store i32 %15, i32* %6
%16 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%17 = load i32, i32* %6
%18 = call i32 @sprintf(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %17)
%19 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%20 = call i32 @execlp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %19, i32* null)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"baz\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c"foo\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [20 x i8]
%4 = tail call i32 (...) @increment_rank()
%5 = tail call i32 @whoami(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = tail call i32 @atoi(i8* %7)
%9 = add nsw i32 %8, -1
%10 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%11 = call i32 @sprintf(i8* %10, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%12 = call i32 @execlp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %10, i32* null)
ret i32 0
}