#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 */
struct mem {
  int dummy;
};
typedef scalar_t__ off_t;

/* Variables and functions */
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ free(struct mem *);
struct mem *mkPmem(char *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  struct mem *pmem1;
  pmem1 = mkPmem("basicprogramtest.txt");
  if (!pmem1) {
    printf("something happened uh oh");
  } else {
    printf("Pmem is: %lld\n", (long long int)(off_t)pmem1);
    printf("\n");
    free(pmem1);
  }
  exit(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
call   1050 <mkPmem@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1184 <main+0x44>
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11ad <main+0x6d>
mov    -0x18(%rbp),%rsi
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
xor    %edi,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xea8(%rip),%rdi
call   1060 <mkPmem@plt>
test   %rax,%rax
jne    1177 <main+0x27>
lea    0xeac(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>
mov    %rax,%rbx
lea    0xead(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
%struct.mem = type { i32 }
@.str = [21 x i8] c"basicprogramtest.txt\00"
@.str.1 = [25 x i8] c"something happened uh oh\00"
@.str.2 = [15 x i8] c"Pmem is: %lld\0A\00"
@.str.3 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.mem*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call %struct.mem* @mkPmem(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
store %struct.mem* %7, %struct.mem** %6
%8 = load %struct.mem*, %struct.mem** %6
%9 = icmp ne %struct.mem* %8, null
br i1 %9, label %12, label %10
10: ; preds = %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
br label %19
12: ; preds = %2
%13 = load %struct.mem*, %struct.mem** %6
%14 = ptrtoint %struct.mem* %13 to i64
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i64 %14)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%17 = load %struct.mem*, %struct.mem** %6
%18 = call i32 @free(%struct.mem* %17)
br label %19
19: ; preds = %12, %10
%20 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.mem = type { i32 }
@.str = [21 x i8] c"basicprogramtest.txt\00"
@.str.1 = [25 x i8] c"something happened uh oh\00"
@.str.2 = [15 x i8] c"Pmem is: %lld\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call %struct.mem* @mkPmem(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq %struct.mem* %3, null
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
br label %12
7: ; preds = %2
%8 = ptrtoint %struct.mem* %3 to i64
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i64 %8)
%10 = tail call i32 @putchar(i32 10)
%11 = tail call i32 @free(%struct.mem* %3)
br label %12
12: ; preds = %7, %5
%13 = tail call i32 @exit(i32 0)
unreachable
}