#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*/ exit(int);
scalar_t__ posix_spawn(int *, char *, int /*<<< orphan*/ *,
                       int /*<<< orphan*/ *, char **, int /*<<< orphan*/ *);
int /*<<< orphan*/ sprintf(char *, char *, int);
int main(int argc, char *argv[]) {
  int left;
  int pid;
  if (argc == 1) {
    exit(1);
  }
  left = atoi(argv[1]);
  left--;
  if (left <= 0) {
    exit(0);
  } else {
    char buffer[80];
    (void)sprintf(buffer, "%d", left);
    argv[1] = buffer;
    if (posix_spawn(&pid, argv[0], NULL, NULL, argv, NULL)) {
      exit(2);
    }
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    116a <main+0x2a>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jg     1194 <main+0x54>
xor    %edi,%edi
call   1060 <exit@plt>
lea    -0x70(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xe5e(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x70(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
mov    -0x10(%rbp),%r8
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%r9d
mov    %r9,%rdx
mov    %r9,%rcx
call   1030 <posix_spawn@plt>
cmp    $0x0,%rax
je     11e6 <main+0xa6>
mov    $0x2,%edi
call   1060 <exit@plt>
jmp    11eb <main+0xab>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x68,%rsp
cmp    $0x1,%edi
je     11a0 <main+0x60>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1040 <atoi@plt>
cmp    $0x1,%eax
jle    11aa <main+0x6a>
add    $0xffffffff,%eax
lea    0xe99(%rip),%rsi
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    %eax,%edx
call   1050 <sprintf@plt>
mov    %r14,0x8(%rbx)
mov    (%rbx),%rsi
lea    0xc(%rsp),%rdi
xor    %edx,%edx
xor    %ecx,%ecx
mov    %rbx,%r8
xor    %r9d,%r9d
call   1030 <posix_spawn@plt>
test   %rax,%rax
jne    11b1 <main+0x71>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r14
ret
mov    $0x1,%edi
call   1060 <exit@plt>
xor    %edi,%edi
call   1060 <exit@plt>
mov    $0x2,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\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 [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 eq i32 %9, 1
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 @exit(i32 1)
unreachable
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 i32, i32* %6
%19 = add nsw i32 %18, -1
store i32 %19, i32* %6
%20 = load i32, i32* %6
%21 = icmp sle i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %13
%23 = call i32 @exit(i32 0)
unreachable
24: ; preds = %13
%25 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%26 = load i32, i32* %6
%27 = call i32 @sprintf(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %26)
%28 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
store i8* %28, i8** %30
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 0
%33 = load i8*, i8** %32
%34 = load i8**, i8*** %5
%35 = call i64 @posix_spawn(i32* %7, i8* %33, i32* null, i32* null, i8** %34, i32* null)
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %24
%38 = call i32 @exit(i32 2)
unreachable
39: ; preds = %24
br label %40
40: ; preds = %39
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca [80 x i8]
%5 = bitcast i32* %3 to i8*
%6 = icmp eq i32 %0, 1
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32 @atoi(i8* %11)
%13 = icmp slt i32 %12, 2
br i1 %13, label %14, label %16
14: ; preds = %9
%15 = tail call i32 @exit(i32 0)
unreachable
16: ; preds = %9
%17 = add nsw i32 %12, -1
%18 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%19 = call i32 @sprintf(i8* %18, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %17)
store i8* %18, i8** %10
%20 = load i8*, i8** %1
%21 = call i64 @posix_spawn(i32* %3, i8* %20, i32* null, i32* null, i8** %1, i32* null)
%22 = icmp eq i64 %21, 0
br i1 %22, label %25, label %23
23: ; preds = %16
%24 = call i32 @exit(i32 2)
unreachable
25: ; preds = %16
ret i32 0
}