#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 EXIT_SUCCESS;
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int count;
  for (count = 99; count >= 0; --count) {
    printf("%d bottle%s of beer on the wall,\n", count, count == 1 ? "" : "s");
    printf("%d bottle%s of beer,\n", count, count == 1 ? "" : "s");
    printf("Take one down,\n");
    printf("Pass it around,\n");
    --count;
    if (count) {
      printf("%d more bottle%s of beer on the wall.\n\n", count,
             count == 1 ? "" : "s");
    } else {
      printf("No more bottles of beer on the wall.\n\n");
    }
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x63,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jl     1200 <main+0xf0>
mov    -0x8(%rbp),%esi
mov    -0x8(%rbp),%ecx
lea    0xee5(%rip),%rdx
lea    0xf3e(%rip),%rax
cmp    $0x1,%ecx
cmove  %rax,%rdx
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
mov    -0x8(%rbp),%ecx
lea    0xebc(%rip),%rdx
lea    0xf15(%rip),%rax
cmp    $0x1,%ecx
cmove  %rax,%rdx
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     11df <main+0xcf>
mov    -0x8(%rbp),%esi
mov    -0x8(%rbp),%ecx
lea    0xe64(%rip),%rdx
lea    0xebd(%rip),%rax
cmp    $0x1,%ecx
cmove  %rax,%rdx
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ed <main+0xdd>
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f2 <main+0xe2>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    1126 <main+0x16>
mov    0x2dd9(%rip),%rax
mov    (%rax),%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
mov    $0x63,%ebx
mov    $0xffffff9e,%r15d
lea    0xf24(%rip),%rbp
lea    0xede(%rip),%r12
lea    0xf26(%rip),%r13
nopl   0x0(%rax,%rax,1)
test   %r15d,%r15d
mov    %r12,%r14
cmove  %rbp,%r14
lea    0xe9f(%rip),%rdi
mov    %ebx,%esi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb0(%rip),%rdi
mov    %ebx,%esi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xedb(%rip),%rdi
call   1030 <puts@plt>
mov    %r13,%rdi
call   1030 <puts@plt>
mov    %ebx,%esi
add    $0xffffffff,%esi
je     11c3 <main+0xa3>
cmp    $0x1,%esi
mov    %r12,%rdx
cmove  %rbp,%rdx
lea    0xe8e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    -0x2(%rbx),%eax
add    $0x2,%r15d
cmp    $0x1,%ebx
mov    %eax,%ebx
ja     1150 <main+0x30>
jmp    11cf <main+0xaf>
lea    0xeb7(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e0a(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [34 x i8] c"%d bottle%s of beer on the wall,\0A\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [2 x i8] c"s\00"
@.str.3 = [22 x i8] c"%d bottle%s of beer,\0A\00"
@.str.4 = [16 x i8] c"Take one down,\0A\00"
@.str.5 = [17 x i8] c"Pass it around,\0A\00"
@.str.6 = [40 x i8] c"%d more bottle%s of beer on the wall.\0A\0A\00"
@.str.7 = [39 x i8] c"No more bottles of beer on the wall.\0A\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
store i32 99, i32* %2
br label %3
3: ; preds = %35, %0
%4 = load i32, i32* %2
%5 = icmp sge i32 %4, 0
br i1 %5, label %6, label %38
6: ; preds = %3
%7 = load i32, i32* %2
%8 = load i32, i32* %2
%9 = icmp eq i32 %8, 1
%10 = zext i1 %9 to i64
%11 = select i1 %9, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %7, i8* %11)
%13 = load i32, i32* %2
%14 = load i32, i32* %2
%15 = icmp eq i32 %14, 1
%16 = zext i1 %15 to i64
%17 = select i1 %15, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %13, i8* %17)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
%21 = load i32, i32* %2
%22 = add nsw i32 %21, -1
store i32 %22, i32* %2
%23 = load i32, i32* %2
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %32
25: ; preds = %6
%26 = load i32, i32* %2
%27 = load i32, i32* %2
%28 = icmp eq i32 %27, 1
%29 = zext i1 %28 to i64
%30 = select i1 %28, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0)
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.6, i64 0, i64 0), i32 %26, i8* %30)
br label %34
32: ; preds = %6
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.7, i64 0, i64 0))
br label %34
34: ; preds = %32, %25
br label %35
35: ; preds = %34
%36 = load i32, i32* %2
%37 = add nsw i32 %36, -1
store i32 %37, i32* %2
br label %3
38: ; preds = %3
%39 = load i32, i32* @EXIT_SUCCESS
ret i32 %39
}

LLVM IR (-O2):
@.str = [34 x i8] c"%d bottle%s of beer on the wall,\0A\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [2 x i8] c"s\00"
@.str.3 = [22 x i8] c"%d bottle%s of beer,\0A\00"
@.str.6 = [40 x i8] c"%d more bottle%s of beer on the wall.\0A\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [15 x i8] c"Take one down,\00"
@str.8 = [16 x i8] c"Pass it around,\00"
@str.9 = [38 x i8] c"No more bottles of beer on the wall.\0A\00"
define i32 @main() {
br label %1
1: ; preds = %0, %13
%2 = phi i32 [ 99, %0 ], [ %17, %13 ]
%3 = icmp eq i32 %2, 1
%4 = select i1 %3, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %2, i8* %4)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %2, i8* %4)
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.8, i64 0, i64 0))
%9 = add nsw i32 %2, -1
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %1
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.9, i64 0, i64 0))
br label %19
13: ; preds = %1
%14 = icmp eq i32 %9, 1
%15 = select i1 %14, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0)
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.6, i64 0, i64 0), i32 %9, i8* %15)
%17 = add nsw i32 %2, -2
%18 = icmp ugt i32 %2, 1
br i1 %18, label %1, label %19
19: ; preds = %13, %11
%20 = load i32, i32* @EXIT_SUCCESS
ret i32 %20
}