#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*/ sleep(int);
void think(int philosopher_id) {
  ++philosopher_id;
  printf("[Philo %d]: thinking...\n", philosopher_id);
  switch (philosopher_id) {
  case 1:
    printf("\x1b[33m"
           "[Philo %d]: 'If I download a movie in Jamaica am I a pirate of the "
           "Caribbeans?'"
           "\x1b[0m"
           "\n",
           philosopher_id);
    break;
  case 2:
    printf("\x1b[33m"
           "[Philo %d]: 'If you spill cleaning product did you make a mess?'"
           "\x1b[0m"
           "\n",
           philosopher_id);
    break;
  case 3:
    printf("\x1b[33m"
           "[Philo %d]: 'If two mindreaders read eachothers minds whould they "
           "just be reading their own mind?'"
           "\x1b[0m"
           "\n",
           philosopher_id);
    break;
  case 4:
    printf(
        "\x1b[33m"
        "[Philo %d]: 'Is an argument between two vegans still called a 'beef'?'"
        "\x1b[0m"
        "\n",
        philosopher_id);
    break;
  case 5:
    printf("\x1b[33m"
           "[Philo %d]: 'At the movie theater which armrest is yours?'"
           "\x1b[0m"
           "\n",
           philosopher_id);
    break;
  default:
    printf("\x1b[33m"
           "[Some Philo] (thinking)..."
           "\x1b[0m"
           "\n");
    break;
  }
  sleep(2);
}


x86 assembly (clang, -O0):
<think>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xed6(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x4,%eax
ja     11dc <think+0xbc>
mov    -0x10(%rbp),%rax
lea    0xe9b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x4(%rbp),%esi
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ea <think+0xca>
mov    -0x4(%rbp),%esi
lea    0xef9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ea <think+0xca>
mov    -0x4(%rbp),%esi
lea    0xf2e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ea <think+0xca>
mov    -0x4(%rbp),%esi
lea    0xf85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ea <think+0xca>
mov    -0x4(%rbp),%esi
lea    0xfc0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ea <think+0xca>
lea    0xff2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x2,%edi
call   1040 <sleep@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<think>:
push   %rbx
mov    %edi,%ebx
lea    0x1(%rbx),%esi
lea    0xed7(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x4,%ebx
ja     1169 <think+0x39>
mov    %ebx,%eax
lea    0xeae(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xecb(%rip),%rdi
mov    $0x1,%esi
jmp    11ad <think+0x7d>
lea    0x1065(%rip),%rdi
call   1030 <puts@plt>
jmp    11b4 <think+0x84>
lea    0xf09(%rip),%rdi
mov    $0x2,%esi
jmp    11ad <think+0x7d>
lea    0xf46(%rip),%rdi
mov    $0x3,%esi
jmp    11ad <think+0x7d>
lea    0xfa5(%rip),%rdi
mov    $0x4,%esi
jmp    11ad <think+0x7d>
lea    0xfe8(%rip),%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x2,%edi
pop    %rbx
jmp    1050 <sleep@plt>

LLVM IR (-O0):
@.str = [25 x i8] c"[Philo %d]: thinking...\0A\00"
@.str.1 = [90 x i8] c"\1B[33m[Philo %d]: 'If I download a movie in Jamaica am I a pirate of the Caribbeans?'\1B[0m\0A\00"
@.str.2 = [75 x i8] c"\1B[33m[Philo %d]: 'If you spill cleaning product did you make a mess?'\1B[0m\0A\00"
@.str.3 = [109 x i8] c"\1B[33m[Philo %d]: 'If two mindreaders read eachothers minds whould they just be reading their own mind?'\1B[0m\0A\00"
@.str.4 = [81 x i8] c"\1B[33m[Philo %d]: 'Is an argument between two vegans still called a 'beef'?'\1B[0m\0A\00"
@.str.5 = [69 x i8] c"\1B[33m[Philo %d]: 'At the movie theater which armrest is yours?'\1B[0m\0A\00"
@.str.6 = [37 x i8] c"\1B[33m[Some Philo] (thinking)...\1B[0m\0A\00"
define void @think(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = add nsw i32 %3, 1
store i32 %4, i32* %2
%5 = load i32, i32* %2
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = load i32, i32* %2
switch i32 %7, label %23 [
i32 1, label %8
i32 2, label %11
i32 3, label %14
i32 4, label %17
i32 5, label %20
]
8: ; preds = %1
%9 = load i32, i32* %2
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([90 x i8], [90 x i8]* @.str.1, i64 0, i64 0), i32 %9)
br label %25
11: ; preds = %1
%12 = load i32, i32* %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.2, i64 0, i64 0), i32 %12)
br label %25
14: ; preds = %1
%15 = load i32, i32* %2
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([109 x i8], [109 x i8]* @.str.3, i64 0, i64 0), i32 %15)
br label %25
17: ; preds = %1
%18 = load i32, i32* %2
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.4, i64 0, i64 0), i32 %18)
br label %25
20: ; preds = %1
%21 = load i32, i32* %2
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.5, i64 0, i64 0), i32 %21)
br label %25
23: ; preds = %1
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0))
br label %25
25: ; preds = %23, %20, %17, %14, %11, %8
%26 = call i32 @sleep(i32 2)
ret void
}

LLVM IR (-O2):
@.str = [25 x i8] c"[Philo %d]: thinking...\0A\00"
@.str.1 = [90 x i8] c"\1B[33m[Philo %d]: 'If I download a movie in Jamaica am I a pirate of the Caribbeans?'\1B[0m\0A\00"
@.str.2 = [75 x i8] c"\1B[33m[Philo %d]: 'If you spill cleaning product did you make a mess?'\1B[0m\0A\00"
@.str.3 = [109 x i8] c"\1B[33m[Philo %d]: 'If two mindreaders read eachothers minds whould they just be reading their own mind?'\1B[0m\0A\00"
@.str.4 = [81 x i8] c"\1B[33m[Philo %d]: 'Is an argument between two vegans still called a 'beef'?'\1B[0m\0A\00"
@.str.5 = [69 x i8] c"\1B[33m[Philo %d]: 'At the movie theater which armrest is yours?'\1B[0m\0A\00"
@str = [36 x i8] c"\1B[33m[Some Philo] (thinking)...\1B[0m\00"
define void @think(i32 %0) {
%2 = add nsw i32 %0, 1
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %2)
switch i32 %0, label %14 [
i32 0, label %4
i32 1, label %6
i32 2, label %8
i32 3, label %10
i32 4, label %12
]
4: ; preds = %1
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([90 x i8], [90 x i8]* @.str.1, i64 0, i64 0), i32 1)
br label %16
6: ; preds = %1
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([75 x i8], [75 x i8]* @.str.2, i64 0, i64 0), i32 2)
br label %16
8: ; preds = %1
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([109 x i8], [109 x i8]* @.str.3, i64 0, i64 0), i32 3)
br label %16
10: ; preds = %1
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([81 x i8], [81 x i8]* @.str.4, i64 0, i64 0), i32 4)
br label %16
12: ; preds = %1
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([69 x i8], [69 x i8]* @.str.5, i64 0, i64 0), i32 5)
br label %16
14: ; preds = %1
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str, i64 0, i64 0))
br label %16
16: ; preds = %14, %12, %10, %8, %6, %4
%17 = tail call i32 @sleep(i32 2)
ret void
}