#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 *, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ snprintf(char *, int, char *, int);
int main(int argc, char **argv) {
  if (argc != 3)
    return 0;
  int accum = atoi(argv[1]);
  int n = atoi(argv[2]);
  if (n == 0) {
    printf("answer: %d\n", accum);
    return accum;
  }
  char p[32] = {0}, q[32] = {0};
  snprintf(p, 31, "%d", accum + n);
  snprintf(q, 31, "%d", n - 1);
  execlp("/proc/self/exe", "exe", p, q, NULL);
  return -1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     117c <main+0x2c>
movl   $0x0,-0x4(%rbp)
jmp    123d <main+0xed>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    11c0 <main+0x70>
mov    -0x14(%rbp),%esi
lea    0xe50(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    123d <main+0xed>
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1050 <memset@plt>
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1050 <memset@plt>
lea    -0x40(%rbp),%rdi
mov    -0x14(%rbp),%ecx
add    -0x18(%rbp),%ecx
mov    $0x1f,%esi
lea    0xe16(%rip),%rdx
call   1040 <snprintf@plt>
lea    -0x60(%rbp),%rdi
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
mov    $0x1f,%esi
lea    0xdfb(%rip),%rdx
call   1040 <snprintf@plt>
lea    -0x40(%rbp),%rdx
lea    -0x60(%rbp),%rcx
lea    0xdea(%rip),%rdi
lea    0xdee(%rip),%rsi
xor    %eax,%eax
mov    %eax,%r8d
call   1070 <execlp@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x48,%rsp
xor    %ebx,%ebx
cmp    $0x3,%edi
jne    11f1 <main+0xb1>
mov    %rsi,%rbp
mov    0x8(%rsi),%rdi
call   1050 <atoi@plt>
mov    %eax,%ebx
mov    0x10(%rbp),%rdi
call   1050 <atoi@plt>
test   %eax,%eax
je     11e3 <main+0xa3>
mov    %eax,%ebp
xorps  %xmm0,%xmm0
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
add    %eax,%ebx
lea    0xe7b(%rip),%r14
lea    0x20(%rsp),%r15
mov    %r15,%rdi
mov    $0x1f,%esi
mov    %r14,%rdx
mov    %ebx,%ecx
call   1040 <snprintf@plt>
add    $0xffffffff,%ebp
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x1f,%esi
mov    %r14,%rdx
mov    %ebp,%ecx
call   1040 <snprintf@plt>
lea    0xe48(%rip),%rdi
lea    0xe4c(%rip),%rsi
mov    %r15,%rdx
mov    %rbx,%rcx
xor    %r8d,%r8d
call   1060 <execlp@plt>
mov    $0xffffffff,%ebx
jmp    11f1 <main+0xb1>
lea    0xe16(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    %ebx,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"answer: %d\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [15 x i8] c"/proc/self/exe\00"
@.str.3 = [4 x i8] c"exe\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca [32 x i8]
%9 = alloca [32 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 3
br i1 %11, label %12, label %13
12: ; preds = %2
store i32 0, i32* %3
br label %43
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @atoi(i8* %16)
store i32 %17, i32* %6
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 2
%20 = load i8*, i8** %19
%21 = call i32 @atoi(i8* %20)
store i32 %21, i32* %7
%22 = load i32, i32* %7
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %28
24: ; preds = %13
%25 = load i32, i32* %6
%26 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %25)
%27 = load i32, i32* %6
store i32 %27, i32* %3
br label %43
28: ; preds = %13
%29 = bitcast [32 x i8]* %8 to i8*
%30 = bitcast [32 x i8]* %9 to i8*
%31 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%32 = load i32, i32* %6
%33 = load i32, i32* %7
%34 = add nsw i32 %32, %33
%35 = call i32 @snprintf(i8* %31, i32 31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %34)
%36 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%37 = load i32, i32* %7
%38 = sub nsw i32 %37, 1
%39 = call i32 @snprintf(i8* %36, i32 31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %38)
%40 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%41 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%42 = call i32 @execlp(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %40, i8* %41, i32* null)
store i32 -1, i32* %3
br label %43
43: ; preds = %28, %24, %12
%44 = load i32, i32* %3
ret i32 %44
}

LLVM IR (-O2):
@.str = [12 x i8] c"answer: %d\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [15 x i8] c"/proc/self/exe\00"
@.str.3 = [4 x i8] c"exe\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [32 x i8]
%4 = alloca [32 x i8]
%5 = icmp eq i32 %0, 3
br i1 %5, label %6, label %24
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @atoi(i8* %8)
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = load i8*, i8** %10
%12 = tail call i32 @atoi(i8* %11)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %6
%15 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %9)
br label %24
16: ; preds = %6
%17 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%18 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%19 = add nsw i32 %12, %9
%20 = call i32 @snprintf(i8* %17, i32 31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %19)
%21 = add nsw i32 %12, -1
%22 = call i32 @snprintf(i8* %18, i32 31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %21)
%23 = call i32 @execlp(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %17, i8* %18, i32* null)
br label %24
24: ; preds = %14, %16, %2
%25 = phi i32 [ 0, %2 ], [ %9, %14 ], [ -1, %16 ]
ret i32 %25
}