#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 /*<<< orphan*/ scanf(char *, int *);
void main() {
  int num;
  int cont = 1;
  while (cont == 1) {
    for (num = -1; (num < 1) || (num > 12);) {
      printf("Please enter an integer in the range [1,12]: ");
      scanf("%d", &num);
    }
    while (num > 0) {
      switch (num) {
      case 1:
        printf("...and a Partridge in a Pear Tree!\n");
        break;
      case 2:
        printf("2 Turtle Doves\n");
        break;
      case 3:
        printf("3 French Hens\n");
        break;
      case 4:
        printf("4 Calling Birds\n");
        break;
      case 5:
        printf("5 Golden Rings\n");
        break;
      case 6:
        printf("6 Geese a Laying\n");
        break;
      case 7:
        printf("7 Swans a Swimming\n");
        break;
      case 8:
        printf("8 Maids a Milking\n");
        break;
      case 9:
        printf("9 Ladies Dancing\n");
        break;
      case 10:
        printf("10 Lords a Leaping\n");
        break;
      case 11:
        printf("11 Pipers Piping\n");
        break;
      case 12:
        printf("12 Drummers Drumming\n");
        break;
      }
      num -= 1;
    }
    printf("Would you like to continue? (1 = yes, 0 = no): ");
    scanf("%d", &cont);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x1,-0x8(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    12b8 <main+0x198>
movl   $0xffffffff,-0x4(%rbp)
mov    $0x1,%al
cmpl   $0x1,-0x4(%rbp)
mov    %al,-0x9(%rbp)
jl     1159 <main+0x39>
cmpl   $0xc,-0x4(%rbp)
setg   %al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
test   $0x1,%al
jne    1169 <main+0x49>
jmp    118a <main+0x6a>
lea    0xec0(%rip),%rdi
call   1030 <printf@plt>
lea    0xee2(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
jmp    1140 <main+0x20>
jmp    118f <main+0x6f>
cmpl   $0x0,-0x4(%rbp)
jle    1297 <main+0x177>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0xb,%eax
ja     1289 <main+0x169>
mov    -0x18(%rbp),%rax
lea    0xe47(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe98(%rip),%rdi
call   1030 <printf@plt>
jmp    1289 <main+0x169>
lea    0xeab(%rip),%rdi
call   1030 <printf@plt>
jmp    1289 <main+0x169>
lea    0xeaa(%rip),%rdi
call   1030 <printf@plt>
jmp    1289 <main+0x169>
lea    0xea8(%rip),%rdi
call   1030 <printf@plt>
jmp    1289 <main+0x169>
lea    0xea8(%rip),%rdi
call   1030 <printf@plt>
jmp    1289 <main+0x169>
lea    0xea7(%rip),%rdi
call   1030 <printf@plt>
jmp    1289 <main+0x169>
lea    0xea8(%rip),%rdi
call   1030 <printf@plt>
jmp    1289 <main+0x169>
lea    0xeab(%rip),%rdi
call   1030 <printf@plt>
jmp    1289 <main+0x169>
lea    0xead(%rip),%rdi
call   1030 <printf@plt>
jmp    1289 <main+0x169>
lea    0xeae(%rip),%rdi
call   1030 <printf@plt>
jmp    1289 <main+0x169>
lea    0xeb1(%rip),%rdi
call   1030 <printf@plt>
jmp    1289 <main+0x169>
lea    0xeb2(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    118f <main+0x6f>
lea    0xeae(%rip),%rdi
call   1030 <printf@plt>
lea    0xdb4(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
jmp    112f <main+0xf>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movl   $0x1,0x4(%rsp)
lea    0xeb6(%rip),%r14
lea    0xedd(%rip),%rbx
mov    %rsp,%r15
lea    0xfe5(%rip),%rbp
lea    0xecf(%rip),%r12
lea    0x4(%rsp),%r13
jmp    118a <main+0x5a>
nopl   0x0(%rax)
mov    %r12,%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1050 <scanf@plt>
cmpl   $0x1,0x4(%rsp)
jne    11e7 <main+0xb7>
movl   $0xffffffff,(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
mov    (%rsp),%eax
lea    -0xd(%rax),%ecx
cmp    $0xfffffff4,%ecx
jb     11a0 <main+0x70>
jmp    11ce <main+0x9e>
mov    (%rsp),%ecx
lea    -0x1(%rcx),%eax
mov    %eax,(%rsp)
cmp    $0x1,%ecx
jle    1170 <main+0x40>
add    $0xffffffff,%eax
cmp    $0xb,%eax
ja     11c0 <main+0x90>
cltq
movslq 0x0(%rbp,%rax,4),%rdi
add    %rbp,%rdi
call   1030 <puts@plt>
jmp    11c0 <main+0x90>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [46 x i8] c"Please enter an integer in the range [1,12]: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [36 x i8] c"...and a Partridge in a Pear Tree!\0A\00"
@.str.3 = [16 x i8] c"2 Turtle Doves\0A\00"
@.str.4 = [15 x i8] c"3 French Hens\0A\00"
@.str.5 = [17 x i8] c"4 Calling Birds\0A\00"
@.str.6 = [16 x i8] c"5 Golden Rings\0A\00"
@.str.7 = [18 x i8] c"6 Geese a Laying\0A\00"
@.str.8 = [20 x i8] c"7 Swans a Swimming\0A\00"
@.str.9 = [19 x i8] c"8 Maids a Milking\0A\00"
@.str.10 = [18 x i8] c"9 Ladies Dancing\0A\00"
@.str.11 = [20 x i8] c"10 Lords a Leaping\0A\00"
@.str.12 = [18 x i8] c"11 Pipers Piping\0A\00"
@.str.13 = [22 x i8] c"12 Drummers Drumming\0A\00"
@.str.14 = [48 x i8] c"Would you like to continue? (1 = yes, 0 = no): \00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
store i32 1, i32* %2
br label %3
3: ; preds = %51, %0
%4 = load i32, i32* %2
%5 = icmp eq i32 %4, 1
br i1 %5, label %6, label %54
6: ; preds = %3
store i32 -1, i32* %1
br label %7
7: ; preds = %15, %6
%8 = load i32, i32* %1
%9 = icmp slt i32 %8, 1
br i1 %9, label %13, label %10
10: ; preds = %7
%11 = load i32, i32* %1
%12 = icmp sgt i32 %11, 12
br label %13
13: ; preds = %10, %7
%14 = phi i1 [ true, %7 ], [ %12, %10 ]
br i1 %14, label %15, label %18
15: ; preds = %13
%16 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
br label %7
18: ; preds = %13
br label %19
19: ; preds = %48, %18
%20 = load i32, i32* %1
%21 = icmp sgt i32 %20, 0
br i1 %21, label %22, label %51
22: ; preds = %19
%23 = load i32, i32* %1
switch i32 %23, label %48 [
i32 1, label %24
i32 2, label %26
i32 3, label %28
i32 4, label %30
i32 5, label %32
i32 6, label %34
i32 7, label %36
i32 8, label %38
i32 9, label %40
i32 10, label %42
i32 11, label %44
i32 12, label %46
]
24: ; preds = %22
%25 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
br label %48
26: ; preds = %22
%27 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
br label %48
28: ; preds = %22
%29 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
br label %48
30: ; preds = %22
%31 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
br label %48
32: ; preds = %22
%33 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
br label %48
34: ; preds = %22
%35 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0))
br label %48
36: ; preds = %22
%37 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0))
br label %48
38: ; preds = %22
%39 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0))
br label %48
40: ; preds = %22
%41 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0))
br label %48
42: ; preds = %22
%43 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.11, i64 0, i64 0))
br label %48
44: ; preds = %22
%45 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.12, i64 0, i64 0))
br label %48
46: ; preds = %22
%47 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.13, i64 0, i64 0))
br label %48
48: ; preds = %22, %46, %44, %42, %40, %38, %36, %34, %32, %30, %28, %26, %24
%49 = load i32, i32* %1
%50 = sub nsw i32 %49, 1
store i32 %50, i32* %1
br label %19
51: ; preds = %19
%52 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.14, i64 0, i64 0))
%53 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
br label %3
54: ; preds = %3
ret void
}

LLVM IR (-O2):
@.str = [46 x i8] c"Please enter an integer in the range [1,12]: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.14 = [48 x i8] c"Would you like to continue? (1 = yes, 0 = no): \00"
@str = [21 x i8] c"12 Drummers Drumming\00"
@str.15 = [17 x i8] c"11 Pipers Piping\00"
@str.16 = [19 x i8] c"10 Lords a Leaping\00"
@str.17 = [17 x i8] c"9 Ladies Dancing\00"
@str.18 = [18 x i8] c"8 Maids a Milking\00"
@str.19 = [19 x i8] c"7 Swans a Swimming\00"
@str.20 = [17 x i8] c"6 Geese a Laying\00"
@str.21 = [15 x i8] c"5 Golden Rings\00"
@str.22 = [16 x i8] c"4 Calling Birds\00"
@str.23 = [14 x i8] c"3 French Hens\00"
@str.24 = [15 x i8] c"2 Turtle Doves\00"
@str.25 = [35 x i8] c"...and a Partridge in a Pear Tree!\00"
@reltable.main = [12 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([35 x i8]* @str.25 to i64), i64 ptrtoint ([12 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([15 x i8]* @str.24 to i64), i64 ptrtoint ([12 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @str.23 to i64), i64 ptrtoint ([12 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([16 x i8]* @str.22 to i64), i64 ptrtoint ([12 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([15 x i8]* @str.21 to i64), i64 ptrtoint ([12 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([17 x i8]* @str.20 to i64), i64 ptrtoint ([12 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([19 x i8]* @str.19 to i64), i64 ptrtoint ([12 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([18 x i8]* @str.18 to i64), i64 ptrtoint ([12 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([17 x i8]* @str.17 to i64), i64 ptrtoint ([12 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([19 x i8]* @str.16 to i64), i64 ptrtoint ([12 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([17 x i8]* @str.15 to i64), i64 ptrtoint ([12 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([21 x i8]* @str to i64), i64 ptrtoint ([12 x i32]* @reltable.main to i64)) to i32)]
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
store i32 1, i32* %2
br label %5
5: ; preds = %25, %0
store i32 -1, i32* %1
br label %6
6: ; preds = %5, %6
%7 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%9 = load i32, i32* %1
%10 = add i32 %9, -13
%11 = icmp ult i32 %10, -12
br i1 %11, label %6, label %12
12: ; preds = %6, %21
%13 = phi i32 [ %23, %21 ], [ %9, %6 ]
%14 = add i32 %13, -1
%15 = icmp ult i32 %14, 12
br i1 %15, label %16, label %21
16: ; preds = %12
%17 = sext i32 %14 to i64
%18 = shl i64 %17, 2
%19 = call i8* @llvm.load.relative.i64(i8* bitcast ([12 x i32]* @reltable.main to i8*), i64 %18)
%20 = call i32 @puts(i8* dereferenceable(1) %19)
br label %21
21: ; preds = %12, %16
%22 = load i32, i32* %1
%23 = add nsw i32 %22, -1
store i32 %23, i32* %1
%24 = icmp sgt i32 %22, 1
br i1 %24, label %12, label %25
25: ; preds = %21
%26 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.14, i64 0, i64 0))
%27 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%28 = load i32, i32* %2
%29 = icmp eq i32 %28, 1
br i1 %29, label %5, label %30
30: ; preds = %25
ret void
}