#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*/ eat(int);
int /*<<< orphan*/ put_forks(int);
int /*<<< orphan*/ take_forks(int);
int /*<<< orphan*/ think(int);
void philosopher(void *i) {
  int *phil = (int *)i;
  int awhile = 5;
  while (awhile--) {
    think(*phil);
    take_forks(*phil);
    eat(*phil);
    put_forks(*phil);
  }
}


x86 assembly (clang, -O0):
<philosopher>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
movl   $0x5,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x14(%rbp)
cmp    $0x0,%eax
je     11a0 <philosopher+0x60>
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
call   1040 <think@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
call   1060 <take_forks@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
call   1030 <eat@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
call   1050 <put_forks@plt>
jmp    115b <philosopher+0x1b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<philosopher>:
push   %rbx
mov    %rdi,%rbx
mov    (%rdi),%edi
call   1040 <think@plt>
mov    (%rbx),%edi
call   1060 <take_forks@plt>
mov    (%rbx),%edi
call   1030 <eat@plt>
mov    (%rbx),%edi
call   1050 <put_forks@plt>
mov    (%rbx),%edi
call   1040 <think@plt>
mov    (%rbx),%edi
call   1060 <take_forks@plt>
mov    (%rbx),%edi
call   1030 <eat@plt>
mov    (%rbx),%edi
call   1050 <put_forks@plt>
mov    (%rbx),%edi
call   1040 <think@plt>
mov    (%rbx),%edi
call   1060 <take_forks@plt>
mov    (%rbx),%edi
call   1030 <eat@plt>
mov    (%rbx),%edi
call   1050 <put_forks@plt>
mov    (%rbx),%edi
call   1040 <think@plt>
mov    (%rbx),%edi
call   1060 <take_forks@plt>
mov    (%rbx),%edi
call   1030 <eat@plt>
mov    (%rbx),%edi
call   1050 <put_forks@plt>
mov    (%rbx),%edi
call   1040 <think@plt>
mov    (%rbx),%edi
call   1060 <take_forks@plt>
mov    (%rbx),%edi
call   1030 <eat@plt>
mov    (%rbx),%edi
pop    %rbx
jmp    1050 <put_forks@plt>

LLVM IR (-O0):
define void @philosopher(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = bitcast i8* %5 to i32*
store i32* %6, i32** %3
store i32 5, i32* %4
br label %7
7: ; preds = %11, %1
%8 = load i32, i32* %4
%9 = add nsw i32 %8, -1
store i32 %9, i32* %4
%10 = icmp ne i32 %8, 0
br i1 %10, label %11, label %24
11: ; preds = %7
%12 = load i32*, i32** %3
%13 = load i32, i32* %12
%14 = call i32 @think(i32 %13)
%15 = load i32*, i32** %3
%16 = load i32, i32* %15
%17 = call i32 @take_forks(i32 %16)
%18 = load i32*, i32** %3
%19 = load i32, i32* %18
%20 = call i32 @eat(i32 %19)
%21 = load i32*, i32** %3
%22 = load i32, i32* %21
%23 = call i32 @put_forks(i32 %22)
br label %7
24: ; preds = %7
ret void
}

LLVM IR (-O2):
define void @philosopher(i8* nocapture %0) {
%2 = bitcast i8* %0 to i32*
%3 = load i32, i32* %2
%4 = tail call i32 @think(i32 %3)
%5 = load i32, i32* %2
%6 = tail call i32 @take_forks(i32 %5)
%7 = load i32, i32* %2
%8 = tail call i32 @eat(i32 %7)
%9 = load i32, i32* %2
%10 = tail call i32 @put_forks(i32 %9)
%11 = load i32, i32* %2
%12 = tail call i32 @think(i32 %11)
%13 = load i32, i32* %2
%14 = tail call i32 @take_forks(i32 %13)
%15 = load i32, i32* %2
%16 = tail call i32 @eat(i32 %15)
%17 = load i32, i32* %2
%18 = tail call i32 @put_forks(i32 %17)
%19 = load i32, i32* %2
%20 = tail call i32 @think(i32 %19)
%21 = load i32, i32* %2
%22 = tail call i32 @take_forks(i32 %21)
%23 = load i32, i32* %2
%24 = tail call i32 @eat(i32 %23)
%25 = load i32, i32* %2
%26 = tail call i32 @put_forks(i32 %25)
%27 = load i32, i32* %2
%28 = tail call i32 @think(i32 %27)
%29 = load i32, i32* %2
%30 = tail call i32 @take_forks(i32 %29)
%31 = load i32, i32* %2
%32 = tail call i32 @eat(i32 %31)
%33 = load i32, i32* %2
%34 = tail call i32 @put_forks(i32 %33)
%35 = load i32, i32* %2
%36 = tail call i32 @think(i32 %35)
%37 = load i32, i32* %2
%38 = tail call i32 @take_forks(i32 %37)
%39 = load i32, i32* %2
%40 = tail call i32 @eat(i32 %39)
%41 = load i32, i32* %2
%42 = tail call i32 @put_forks(i32 %41)
ret void
}