#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*/ free(int *);
int /*<<< orphan*/ gabeln_abgeben(int);
int /*<<< orphan*/ gabeln_holen(int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ sleep(int);
void *phil(void *arg) {
  int *argi = (int *)arg;
  int nr = *argi;
  int i;
  printf("Philosoph %d gestartet\n", nr);
  for (i = 0; i < 5; i++) {
    gabeln_holen(nr);
    printf("Philosoph %d isst\n", nr);
    sleep(nr / 2);
    gabeln_abgeben(nr);
    sleep(1);
  }
  printf("Philosoph %d ist fertig\n", nr);
  free(argi);
  return NULL;
}


x86 assembly (clang, -O0):
<phil>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe89(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x18(%rbp)
cmpl   $0x5,-0x18(%rbp)
jge    11d6 <phil+0x86>
mov    -0x14(%rbp),%edi
call   1060 <gabeln_holen@plt>
mov    -0x14(%rbp),%esi
lea    0xe79(%rip),%rdi
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1070 <sleep@plt>
mov    -0x14(%rbp),%edi
call   1050 <gabeln_abgeben@plt>
mov    $0x1,%edi
call   1070 <sleep@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1183 <phil+0x33>
mov    -0x14(%rbp),%esi
lea    0xe4b(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<phil>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    (%rdi),%ebp
lea    0xe9d(%rip),%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
mov    %ebp,%ebx
shr    $0x1f,%ebx
add    %ebp,%ebx
sar    %ebx
mov    %ebp,%edi
call   1060 <gabeln_holen@plt>
lea    0xe97(%rip),%r15
mov    %r15,%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
mov    %ebx,%edi
call   1070 <sleep@plt>
mov    %ebp,%edi
call   1050 <gabeln_abgeben@plt>
mov    $0x1,%edi
call   1070 <sleep@plt>
mov    %ebp,%edi
call   1060 <gabeln_holen@plt>
mov    %r15,%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
mov    %ebx,%edi
call   1070 <sleep@plt>
mov    %ebp,%edi
call   1050 <gabeln_abgeben@plt>
mov    $0x1,%edi
call   1070 <sleep@plt>
mov    %ebp,%edi
call   1060 <gabeln_holen@plt>
mov    %r15,%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
mov    %ebx,%edi
call   1070 <sleep@plt>
mov    %ebp,%edi
call   1050 <gabeln_abgeben@plt>
mov    $0x1,%edi
call   1070 <sleep@plt>
mov    %ebp,%edi
call   1060 <gabeln_holen@plt>
mov    %r15,%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
mov    %ebx,%edi
call   1070 <sleep@plt>
mov    %ebp,%edi
call   1050 <gabeln_abgeben@plt>
mov    $0x1,%edi
call   1070 <sleep@plt>
mov    %ebp,%edi
call   1060 <gabeln_holen@plt>
mov    %r15,%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
mov    %ebx,%edi
call   1070 <sleep@plt>
mov    %ebp,%edi
call   1050 <gabeln_abgeben@plt>
mov    $0x1,%edi
call   1070 <sleep@plt>
lea    0xddd(%rip),%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [24 x i8] c"Philosoph %d gestartet\0A\00"
@.str.1 = [19 x i8] c"Philosoph %d isst\0A\00"
@.str.2 = [25 x i8] c"Philosoph %d ist fertig\0A\00"
define i8* @phil(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = bitcast i8* %6 to i32*
store i32* %7, i32** %3
%8 = load i32*, i32** %3
%9 = load i32, i32* %8
store i32 %9, i32* %4
%10 = load i32, i32* %4
%11 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %10)
store i32 0, i32* %5
br label %12
12: ; preds = %26, %1
%13 = load i32, i32* %5
%14 = icmp slt i32 %13, 5
br i1 %14, label %15, label %29
15: ; preds = %12
%16 = load i32, i32* %4
%17 = call i32 @gabeln_holen(i32 %16)
%18 = load i32, i32* %4
%19 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %18)
%20 = load i32, i32* %4
%21 = sdiv i32 %20, 2
%22 = call i32 @sleep(i32 %21)
%23 = load i32, i32* %4
%24 = call i32 @gabeln_abgeben(i32 %23)
%25 = call i32 @sleep(i32 1)
br label %26
26: ; preds = %15
%27 = load i32, i32* %5
%28 = add nsw i32 %27, 1
store i32 %28, i32* %5
br label %12
29: ; preds = %12
%30 = load i32, i32* %4
%31 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %30)
%32 = load i32*, i32** %3
%33 = call i32 @free(i32* %32)
ret i8* null
}

LLVM IR (-O2):
@.str = [24 x i8] c"Philosoph %d gestartet\0A\00"
@.str.1 = [19 x i8] c"Philosoph %d isst\0A\00"
@.str.2 = [25 x i8] c"Philosoph %d ist fertig\0A\00"
define noalias i8* @phil(i8* nocapture %0) {
%2 = bitcast i8* %0 to i32*
%3 = load i32, i32* %2
%4 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = sdiv i32 %3, 2
%6 = tail call i32 @gabeln_holen(i32 %3)
%7 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %3)
%8 = tail call i32 @sleep(i32 %5)
%9 = tail call i32 @gabeln_abgeben(i32 %3)
%10 = tail call i32 @sleep(i32 1)
%11 = tail call i32 @gabeln_holen(i32 %3)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %3)
%13 = tail call i32 @sleep(i32 %5)
%14 = tail call i32 @gabeln_abgeben(i32 %3)
%15 = tail call i32 @sleep(i32 1)
%16 = tail call i32 @gabeln_holen(i32 %3)
%17 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %3)
%18 = tail call i32 @sleep(i32 %5)
%19 = tail call i32 @gabeln_abgeben(i32 %3)
%20 = tail call i32 @sleep(i32 1)
%21 = tail call i32 @gabeln_holen(i32 %3)
%22 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %3)
%23 = tail call i32 @sleep(i32 %5)
%24 = tail call i32 @gabeln_abgeben(i32 %3)
%25 = tail call i32 @sleep(i32 1)
%26 = tail call i32 @gabeln_holen(i32 %3)
%27 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %3)
%28 = tail call i32 @sleep(i32 %5)
%29 = tail call i32 @gabeln_abgeben(i32 %3)
%30 = tail call i32 @sleep(i32 1)
%31 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %3)
%32 = tail call i32 @free(i32* %2)
ret i8* null
}