#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 *);
scalar_t__ check_number(int, int);
int /*<<< orphan*/ printf(char *, int, char *);
int main(int argc, char *argv[]) {
  int n = atoi(argv[1]), i = 0;
  while (n) {
    i += check_number(n, 9);
    n--;
  }
  printf("there are %d 9 beetwin 1 and  %s\n", i, argv[1]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     118f <main+0x5f>
mov    -0x14(%rbp),%edi
mov    $0x9,%esi
call   1040 <check_number@plt>
mov    %rax,%rcx
movslq -0x18(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    115d <main+0x2d>
mov    -0x18(%rbp),%esi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe5f(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    0x8(%rsi),%r15
mov    %r15,%rdi
call   1050 <atoi@plt>
test   %eax,%eax
je     1169 <main+0x39>
mov    %eax,%ebp
xor    %ebx,%ebx
xchg   %ax,%ax
mov    %ebp,%edi
mov    $0x9,%esi
call   1040 <check_number@plt>
add    %eax,%ebx
add    $0xffffffff,%ebp
jne    1150 <main+0x20>
mov    0x8(%r14),%r15
jmp    116b <main+0x3b>
xor    %ebx,%ebx
lea    0xe8e(%rip),%rdi
mov    %ebx,%esi
mov    %r15,%rdx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [34 x i8] c"there are %d 9 beetwin 1 and %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i8**, i8*** %5
%9 = getelementptr inbounds i8*, i8** %8, i64 1
%10 = load i8*, i8** %9
%11 = call i32 @atoi(i8* %10)
store i32 %11, i32* %6
store i32 0, i32* %7
br label %12
12: ; preds = %15, %2
%13 = load i32, i32* %6
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %24
15: ; preds = %12
%16 = load i32, i32* %6
%17 = call i64 @check_number(i32 %16, i32 9)
%18 = load i32, i32* %7
%19 = sext i32 %18 to i64
%20 = add nsw i64 %19, %17
%21 = trunc i64 %20 to i32
store i32 %21, i32* %7
%22 = load i32, i32* %6
%23 = add nsw i32 %22, -1
store i32 %23, i32* %6
br label %12
24: ; preds = %12
%25 = load i32, i32* %7
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %25, i8* %28)
ret i32 0
}

LLVM IR (-O2):
@.str = [34 x i8] c"there are %d 9 beetwin 1 and %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i32 @atoi(i8* %4)
%6 = icmp eq i32 %5, 0
br i1 %6, label %17, label %7
7: ; preds = %2, %7
%8 = phi i32 [ %12, %7 ], [ 0, %2 ]
%9 = phi i32 [ %13, %7 ], [ %5, %2 ]
%10 = tail call i64 @check_number(i32 %9, i32 9)
%11 = trunc i64 %10 to i32
%12 = add i32 %8, %11
%13 = add nsw i32 %9, -1
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %7
15: ; preds = %7
%16 = load i8*, i8** %3
br label %17
17: ; preds = %15, %2
%18 = phi i8* [ %4, %2 ], [ %16, %15 ]
%19 = phi i32 [ 0, %2 ], [ %12, %15 ]
%20 = tail call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %19, i8* %18)
ret i32 0
}