#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 /*<<< orphan*/ printf(char *, ...);
int main() {
  int n_beers = 99;
  char pl = 's';
  goto a;
z:
  return 0;
b:
  n_beers--;
  if (n_beers) {
    pl = (n_beers == 1 ? 31 : 's');
    printf("%d bottle%c of beer on the wall!\n", n_beers, pl);
    goto a;
  } else {
    printf("no more bottles of beer on the wall!\n");
    printf("No more bottles of beer on the wall,"
           " no more bottles of beer.\nGo to the store"
           " and buy some more, 99 bottles of beer on the wall!\n");
    goto z;
  }
a:
  printf("%d bottle%c of beer on the wall, "
         "%d bottle%c of beer\n",
         n_beers, pl, n_beers, pl);
  printf("Take one down and pass it around, ");
  goto b;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x63,-0x8(%rbp)
movb   $0x73,-0x9(%rbp)
jmp    119b <main+0x8b>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     117a <main+0x6a>
mov    -0x8(%rbp),%edx
mov    $0x73,%eax
mov    $0x1f,%ecx
cmp    $0x1,%edx
cmove  %ecx,%eax
mov    %al,-0x9(%rbp)
mov    -0x8(%rbp),%esi
movsbl -0x9(%rbp),%edx
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    119b <main+0x8b>
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    112f <main+0x1f>
mov    -0x8(%rbp),%esi
movsbl -0x9(%rbp),%edx
mov    -0x8(%rbp),%ecx
movsbl -0x9(%rbp),%r8d
lea    0xf19(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf41(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1137 <main+0x27>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xef0(%rip),%r14
mov    %r14,%rdi
mov    $0x63,%esi
mov    $0x73,%edx
mov    $0x63,%ecx
mov    $0x73,%r8d
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf00(%rip),%r15
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x62,%ebp
mov    $0x1f,%r13d
lea    0xe8c(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    $0x1,%ebp
mov    $0x73,%ebx
cmove  %r13d,%ebx
mov    %r12,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
mov    %ebp,%ecx
mov    %ebx,%r8d
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0xffffffff,%ebp
jne    1180 <main+0x60>
lea    0xeb8(%rip),%rdi
call   1030 <puts@plt>
lea    0xed1(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%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%c of beer on the wall!\0A\00"
@.str.1 = [38 x i8] c"no more bottles of beer on the wall!\0A\00"
@.str.2 = [130 x i8] c"No more bottles of beer on the wall, no more bottles of beer.\0AGo to the store and buy some more, 99 bottles of beer on the wall!\0A\00"
@.str.3 = [54 x i8] c"%d bottle%c of beer on the wall, %d bottle%c of beer\0A\00"
@.str.4 = [35 x i8] c"Take one down and pass it around, \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8
store i32 0, i32* %1
store i32 99, i32* %2
store i8 115, i8* %3
br label %23
4: ; preds = %20
ret i32 0
5: ; preds = %23
%6 = load i32, i32* %2
%7 = add nsw i32 %6, -1
store i32 %7, i32* %2
%8 = load i32, i32* %2
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %20
10: ; preds = %5
%11 = load i32, i32* %2
%12 = icmp eq i32 %11, 1
%13 = zext i1 %12 to i64
%14 = select i1 %12, i32 31, i32 115
%15 = trunc i32 %14 to i8
store i8 %15, i8* %3
%16 = load i32, i32* %2
%17 = load i8, i8* %3
%18 = sext i8 %17 to i32
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %16, i32 %18)
br label %23
20: ; preds = %5
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([130 x i8], [130 x i8]* @.str.2, i64 0, i64 0))
br label %4
23: ; preds = %10, %0
%24 = load i32, i32* %2
%25 = load i8, i8* %3
%26 = sext i8 %25 to i32
%27 = load i32, i32* %2
%28 = load i8, i8* %3
%29 = sext i8 %28 to i32
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.3, i64 0, i64 0), i32 %24, i32 %26, i32 %27, i32 %29)
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0))
br label %5
}

LLVM IR (-O2):
@.str = [34 x i8] c"%d bottle%c of beer on the wall!\0A\00"
@.str.3 = [54 x i8] c"%d bottle%c of beer on the wall, %d bottle%c of beer\0A\00"
@.str.4 = [35 x i8] c"Take one down and pass it around, \00"
@str = [37 x i8] c"no more bottles of beer on the wall!\00"
@str.5 = [129 x i8] c"No more bottles of beer on the wall, no more bottles of beer.\0AGo to the store and buy some more, 99 bottles of beer on the wall!\00"
define i32 @main() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.3, i64 0, i64 0), i32 99, i32 115, i32 99, i32 115)
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0))
br label %3
3: ; preds = %0, %3
%4 = phi i32 [ 98, %0 ], [ %10, %3 ]
%5 = icmp eq i32 %4, 1
%6 = select i1 %5, i32 31, i32 115
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %4, i32 %6)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.3, i64 0, i64 0), i32 %4, i32 %6, i32 %4, i32 %6)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0))
%10 = add nsw i32 %4, -1
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %3
12: ; preds = %3
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([129 x i8], [129 x i8]* @str.5, i64 0, i64 0))
ret i32 0
}