#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 *, ...);
void ft_takes_place(int hour) {
  int h;
  h = hour;
  if (hour > 12)
    h = hour % 12;
  if (hour == 0)
    h = 12;
  printf("THE FOLLOWING TAKES PLACE BETWEEN");
  if (hour < 11)
    printf("%d.00 AM. AND %d.00 A.M.\n", h, (h + 1) % 12);
  if (hour == 11)
    printf("11.00 AM. AND 12.00 P.M.\n");
  if (hour == 23)
    printf("11.00 P.M. AND 12.00 A.M.\n");
  if (hour == 24)
    printf("12.00 A.M. AND 1.00 A.M.\n");
  else
    printf("%d.00 AM. AND %d.00 A.M.\n", h, (h + 1) % 12);
}


x86 assembly (clang, -O0):
<ft_takes_place>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
cmpl   $0xc,-0x4(%rbp)
jle    1139 <ft_takes_place+0x29>
mov    -0x4(%rbp),%eax
mov    $0xc,%ecx
cltd
idiv   %ecx
mov    %edx,-0x8(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    114a <ft_takes_place+0x3a>
movl   $0xc,-0x8(%rbp)
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0xb,-0x4(%rbp)
jge    1181 <ft_takes_place+0x71>
mov    -0x8(%rbp),%esi
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    $0xc,%ecx
cltd
idiv   %ecx
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0xb,-0x4(%rbp)
jne    1199 <ft_takes_place+0x89>
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x17,-0x4(%rbp)
jne    11b1 <ft_takes_place+0xa1>
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x18,-0x4(%rbp)
jne    11ce <ft_takes_place+0xbe>
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ed <ft_takes_place+0xdd>
mov    -0x8(%rbp),%esi
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    $0xc,%ecx
cltd
idiv   %ecx
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_takes_place>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
mov    %edi,%eax
cmp    $0xd,%edi
jl     114d <ft_takes_place+0x2d>
movslq %ebp,%rax
imul   $0x2aaaaaab,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x21,%rax
add    %ecx,%eax
shl    $0x2,%eax
lea    (%rax,%rax,2),%ecx
mov    %ebp,%eax
sub    %ecx,%eax
test   %ebp,%ebp
mov    $0xc,%ebx
cmovne %eax,%ebx
lea    0xea2(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0xa,%ebp
jg     11a1 <ft_takes_place+0x81>
lea    0x1(%rbx),%eax
cltq
imul   $0x2aaaaaab,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x21,%rax
add    %ecx,%eax
shl    $0x2,%eax
lea    (%rax,%rax,2),%eax
neg    %eax
lea    (%rbx,%rax,1),%edx
add    $0x1,%edx
lea    0xe8a(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0xb,%ebp
je     11b9 <ft_takes_place+0x99>
cmp    $0x18,%ebp
je     1202 <ft_takes_place+0xe2>
cmp    $0x17,%ebp
jne    11c5 <ft_takes_place+0xa5>
lea    0xe9e(%rip),%rdi
jmp    11c0 <ft_takes_place+0xa0>
lea    0xeaf(%rip),%rdi
call   1030 <puts@plt>
lea    0x1(%rbx),%eax
cltq
imul   $0x2aaaaaab,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x21,%rax
add    %ecx,%eax
shl    $0x2,%eax
lea    (%rax,%rax,2),%eax
neg    %eax
lea    (%rbx,%rax,1),%edx
add    $0x1,%edx
lea    0xe2f(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <printf@plt>
lea    0xe33(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [34 x i8] c"THE FOLLOWING TAKES PLACE BETWEEN\00"
@.str.1 = [26 x i8] c"%d.00 AM. AND %d.00 A.M.\0A\00"
@.str.2 = [26 x i8] c"11.00 AM. AND 12.00 P.M.\0A\00"
@.str.3 = [27 x i8] c"11.00 P.M. AND 12.00 A.M.\0A\00"
@.str.4 = [26 x i8] c"12.00 A.M. AND 1.00 A.M.\0A\00"
define void @ft_takes_place(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
store i32 %4, i32* %3
%5 = load i32, i32* %2
%6 = icmp sgt i32 %5, 12
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = load i32, i32* %2
%9 = srem i32 %8, 12
store i32 %9, i32* %3
br label %10
10: ; preds = %7, %1
%11 = load i32, i32* %2
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %10
store i32 12, i32* %3
br label %14
14: ; preds = %13, %10
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%16 = load i32, i32* %2
%17 = icmp slt i32 %16, 11
br i1 %17, label %18, label %24
18: ; preds = %14
%19 = load i32, i32* %3
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
%22 = srem i32 %21, 12
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %19, i32 %22)
br label %24
24: ; preds = %18, %14
%25 = load i32, i32* %2
%26 = icmp eq i32 %25, 11
br i1 %26, label %27, label %29
27: ; preds = %24
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %29
29: ; preds = %27, %24
%30 = load i32, i32* %2
%31 = icmp eq i32 %30, 23
br i1 %31, label %32, label %34
32: ; preds = %29
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
br label %34
34: ; preds = %32, %29
%35 = load i32, i32* %2
%36 = icmp eq i32 %35, 24
br i1 %36, label %37, label %39
37: ; preds = %34
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
br label %45
39: ; preds = %34
%40 = load i32, i32* %3
%41 = load i32, i32* %3
%42 = add nsw i32 %41, 1
%43 = srem i32 %42, 12
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %40, i32 %43)
br label %45
45: ; preds = %39, %37
ret void
}

LLVM IR (-O2):
@.str = [34 x i8] c"THE FOLLOWING TAKES PLACE BETWEEN\00"
@.str.1 = [26 x i8] c"%d.00 AM. AND %d.00 A.M.\0A\00"
@str = [25 x i8] c"12.00 A.M. AND 1.00 A.M.\00"
@str.5 = [26 x i8] c"11.00 P.M. AND 12.00 A.M.\00"
@str.6 = [25 x i8] c"11.00 AM. AND 12.00 P.M.\00"
define void @ft_takes_place(i32 %0) {
%2 = icmp sgt i32 %0, 12
%3 = srem i32 %0, 12
%4 = select i1 %2, i32 %3, i32 %0
%5 = icmp eq i32 %0, 0
%6 = select i1 %5, i32 12, i32 %4
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%8 = icmp slt i32 %0, 11
br i1 %8, label %9, label %13
9: ; preds = %1
%10 = add nsw i32 %6, 1
%11 = srem i32 %10, 12
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %6, i32 %11)
br label %13
13: ; preds = %9, %1
switch i32 %0, label %20 [
i32 11, label %17
i32 23, label %14
i32 24, label %15
]
14: ; preds = %13
br label %17
15: ; preds = %13
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
br label %24
17: ; preds = %13, %14
%18 = phi i8* [ getelementptr inbounds ([26 x i8], [26 x i8]* @str.5, i64 0, i64 0), %14 ], [ getelementptr inbounds ([25 x i8], [25 x i8]* @str.6, i64 0, i64 0), %13 ]
%19 = tail call i32 @puts(i8* dereferenceable(1) %18)
br label %20
20: ; preds = %17, %13
%21 = add nsw i32 %6, 1
%22 = srem i32 %21, 12
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %6, i32 %22)
br label %24
24: ; preds = %20, %15
ret void
}