#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 GetInt();
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  printf("How many bottles will there be? ");
  int n = GetInt();
  if (n < 1) {
    printf("Sorry, that makes no sense.\n");
    return 1;
  }
  printf("\n");
  for (int i = n; i > 0; i--) {
    printf("%d bottle(s) of beer on the wall,\n", i);
    printf("%d bottle(s) of beer,\n", i);
    printf("Take one down, pass it around,\n");
    printf("%d bottle(s) of beer on the wall.\n\n", i - 1);
  }
  printf("Wow, that's annoying.\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <GetInt@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x1,-0x8(%rbp)
jge    116b <main+0x4b>
lea    0xec9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11f0 <main+0xd0>
lea    0xf48(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    11db <main+0xbb>
mov    -0xc(%rbp),%esi
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
sub    $0x1,%esi
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    117f <main+0x5f>
lea    0xeda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xeae(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1060 <GetInt@plt>
test   %eax,%eax
jle    11d6 <main+0x96>
mov    %eax,%ebx
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xecd(%rip),%r12
lea    0xf17(%rip),%r13
lea    0xed6(%rip),%r14
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
lea    0xe8a(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r12,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r13,%rdi
call   1040 <puts@plt>
lea    -0x1(%rbx),%r15d
mov    %r14,%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
cmp    $0x1,%ebx
mov    %r15d,%ebx
ja     1190 <main+0x50>
lea    0xeab(%rip),%rdi
jmp    11e2 <main+0xa2>
mov    $0x1,%ebp
lea    0xed2(%rip),%rdi
call   1040 <puts@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [33 x i8] c"How many bottles will there be? \00"
@.str.1 = [29 x i8] c"Sorry, that makes no sense.\0A\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [35 x i8] c"%d bottle(s) of beer on the wall,\0A\00"
@.str.4 = [23 x i8] c"%d bottle(s) of beer,\0A\00"
@.str.5 = [32 x i8] c"Take one down, pass it around,\0A\00"
@.str.6 = [36 x i8] c"%d bottle(s) of beer on the wall.\0A\0A\00"
@.str.7 = [23 x i8] c"Wow, that's annoying.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (...) @GetInt()
store i32 %5, i32* %2
%6 = load i32, i32* %2
%7 = icmp slt i32 %6, 1
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %1
br label %30
10: ; preds = %0
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%12 = load i32, i32* %2
store i32 %12, i32* %3
br label %13
13: ; preds = %25, %10
%14 = load i32, i32* %3
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %28
16: ; preds = %13
%17 = load i32, i32* %3
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i32 %17)
%19 = load i32, i32* %3
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %19)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0))
%22 = load i32, i32* %3
%23 = sub nsw i32 %22, 1
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0), i32 %23)
br label %25
25: ; preds = %16
%26 = load i32, i32* %3
%27 = add nsw i32 %26, -1
store i32 %27, i32* %3
br label %13
28: ; preds = %13
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0))
store i32 0, i32* %1
br label %30
30: ; preds = %28, %8
%31 = load i32, i32* %1
ret i32 %31
}

LLVM IR (-O2):
@.str = [33 x i8] c"How many bottles will there be? \00"
@.str.3 = [35 x i8] c"%d bottle(s) of beer on the wall,\0A\00"
@.str.4 = [23 x i8] c"%d bottle(s) of beer,\0A\00"
@.str.6 = [36 x i8] c"%d bottle(s) of beer on the wall.\0A\0A\00"
@str = [22 x i8] c"Wow, that's annoying.\00"
@str.8 = [31 x i8] c"Take one down, pass it around,\00"
@str.9 = [28 x i8] c"Sorry, that makes no sense.\00"
define i32 @main() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 (...) @GetInt()
%3 = icmp slt i32 %2, 1
br i1 %3, label %14, label %4
4: ; preds = %0
%5 = tail call i32 @putchar(i32 10)
br label %6
6: ; preds = %4, %6
%7 = phi i32 [ %2, %4 ], [ %11, %6 ]
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i32 %7)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %7)
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.8, i64 0, i64 0))
%11 = add nsw i32 %7, -1
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0), i32 %11)
%13 = icmp ugt i32 %7, 1
br i1 %13, label %6, label %14
14: ; preds = %6, %0
%15 = phi i8* [ getelementptr inbounds ([28 x i8], [28 x i8]* @str.9, i64 0, i64 0), %0 ], [ getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0), %6 ]
%16 = phi i32 [ 1, %0 ], [ 0, %6 ]
%17 = tail call i32 @puts(i8* dereferenceable(1) %15)
ret i32 %16
}