#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 */
typedef int key_t;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int ftok(char *, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char *argv[]) {
  key_t shmkey =
      ftok("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
           "2022-01-22/02-19-57/repos/gwq5210/os/refs/heads/master/ftok.c",
           1);
  if (shmkey == -1) {
    perror("ftok");
    exit(EXIT_FAILURE);
  }
  printf("shmkey = %d\n", shmkey);
  printf("shmkey = 0x%x\n", shmkey);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xea3(%rip),%rdi
mov    $0x1,%esi
call   1060 <ftok@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    118e <main+0x4e>
lea    0xf03(%rip),%rdi
call   1040 <perror@plt>
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
mov    -0x14(%rbp),%esi
lea    0xeeb(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xee9(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xeb8(%rip),%rdi
mov    $0x1,%esi
call   1060 <ftok@plt>
cmp    $0xffffffff,%eax
je     1179 <main+0x39>
mov    %eax,%ebx
lea    0xf23(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
lea    0xf22(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret
lea    0xefe(%rip),%rdi
call   1040 <perror@plt>
mov    0x2e54(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [126 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/gwq5210/os/refs/heads/master/ftok.c\00"
@.str.1 = [5 x i8] c"ftok\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [13 x i8] c"shmkey = %d\0A\00"
@.str.3 = [15 x i8] c"shmkey = 0x%x\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i32 @ftok(i8* getelementptr inbounds ([126 x i8], [126 x i8]* @.str, i64 0, i64 0), i32 1)
store i32 %7, i32* %6
%8 = load i32, i32* %6
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%12 = load i32, i32* @EXIT_FAILURE
%13 = call i32 @exit(i32 %12)
unreachable
14: ; preds = %2
%15 = load i32, i32* %6
%16 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%17 = load i32, i32* %6
%18 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %17)
ret i32 0
}

LLVM IR (-O2):
@.str = [126 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/gwq5210/os/refs/heads/master/ftok.c\00"
@.str.1 = [5 x i8] c"ftok\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [13 x i8] c"shmkey = %d\0A\00"
@.str.3 = [15 x i8] c"shmkey = 0x%x\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @ftok(i8* getelementptr inbounds ([126 x i8], [126 x i8]* @.str, i64 0, i64 0), i32 1)
%4 = icmp eq i32 %3, -1
br i1 %4, label %5, label %9
5: ; preds = %2
%6 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%7 = load i32, i32* @EXIT_FAILURE
%8 = tail call i32 @exit(i32 %7)
unreachable
9: ; preds = %2
%10 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %3)
%11 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %3)
ret i32 0
}