#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 /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ compiles_and_runs(char *, int);
int /*<<< orphan*/ fatal_error(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *);
void get_integer_typedefs(FILE *file) {
  fprintf(file, "\n// Integer types (we assume int >= 32 bits)\n");
  if (sizeof(char) != 1)
    fatal_error("Expecting sizeof(char) == 1");
  if (sizeof(int) < 4)
    fatal_error("Expecting sizeof(int) >= 4");
  fprintf(file, "typedef char int8;\ntypedef unsigned char uint8;\n");
  if (sizeof(short) != 2)
    fatal_error("Can not find 2 byte integer type");
  fprintf(file, "typedef short int16;\ntypedef unsigned short uint16;\n");
  if (sizeof(short) == 4) {
    fprintf(file, "typedef short int32;\ntypedef unsigned short uint32;\n");
  } else if (sizeof(int) == 4) {
    fprintf(file, "typedef int int32;\ntypedef unsigned int uint32;\n");
  } else {
    fatal_error("Can not find 4 byte integer type");
  }
  if (sizeof(long int) == 8) {
    fprintf(file, "typedef long int64;\ntypedef unsigned long uint64;\n");
  } else {
    if (compiles_and_runs("int main() { return sizeof(long long int) != 8; }\n",
                          1)) {
      fprintf(file, "typedef long long int int64;\ntypedef unsigned long long "
                    "int uint64;\n");
    } else {
      fatal_error("Can not find 8 byte integer type");
    }
  }
  if (!compiles_and_runs("int main() { off64_t a = 1; return 0; }\n", 0)) {
    fprintf(file, "typedef int64 off64_t;\n");
  }
}


x86 assembly (clang, -O0):
<get_integer_typedefs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xec9(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xee7(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xf08(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xf2d(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xf4e(%rip),%rsi
call   1030 <fprintf@plt>
lea    0xf75(%rip),%rdi
xor    %esi,%esi
call   1040 <compiles_and_runs@plt>
cmp    $0x0,%rax
jne    11a4 <get_integer_typedefs+0x84>
mov    -0x8(%rbp),%rdi
lea    0xf82(%rip),%rsi
call   1030 <fprintf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_integer_typedefs>:
push   %rbx
mov    %rdi,%rbx
lea    0xed5(%rip),%rdi
mov    $0x2d,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fwrite@plt>
lea    0xeea(%rip),%rdi
mov    $0x30,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fwrite@plt>
lea    0xf02(%rip),%rdi
mov    $0x34,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fwrite@plt>
lea    0xf1e(%rip),%rdi
mov    $0x30,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fwrite@plt>
lea    0xf36(%rip),%rdi
mov    $0x32,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fwrite@plt>
lea    0xf50(%rip),%rdi
xor    %esi,%esi
call   1030 <compiles_and_runs@plt>
test   %rax,%rax
je     11b6 <get_integer_typedefs+0x96>
pop    %rbx
ret
lea    0xf64(%rip),%rdi
mov    $0x17,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
pop    %rbx
jmp    1040 <fwrite@plt>

LLVM IR (-O0):
@.str = [46 x i8] c"\0A// Integer types (we assume int >= 32 bits)\0A\00"
@.str.1 = [49 x i8] c"typedef char int8;\0Atypedef unsigned char uint8;\0A\00"
@.str.2 = [53 x i8] c"typedef short int16;\0Atypedef unsigned short uint16;\0A\00"
@.str.3 = [49 x i8] c"typedef int int32;\0Atypedef unsigned int uint32;\0A\00"
@.str.4 = [51 x i8] c"typedef long int64;\0Atypedef unsigned long uint64;\0A\00"
@.str.5 = [41 x i8] c"int main() { off64_t a = 1; return 0; }\0A\00"
@.str.6 = [24 x i8] c"typedef int64 off64_t;\0A\00"
define void @get_integer_typedefs(i32* %0) {
%2 = alloca i32*
store i32* %0, i32** %2
%3 = load i32*, i32** %2
%4 = call i32 @fprintf(i32* %3, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%5 = load i32*, i32** %2
%6 = call i32 @fprintf(i32* %5, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0))
%7 = load i32*, i32** %2
%8 = call i32 @fprintf(i32* %7, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.2, i64 0, i64 0))
%9 = load i32*, i32** %2
%10 = call i32 @fprintf(i32* %9, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.3, i64 0, i64 0))
%11 = load i32*, i32** %2
%12 = call i32 @fprintf(i32* %11, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.4, i64 0, i64 0))
%13 = call i64 @compiles_and_runs(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0), i32 0)
%14 = icmp ne i64 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %1
%16 = load i32*, i32** %2
%17 = call i32 @fprintf(i32* %16, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0))
br label %18
18: ; preds = %15, %1
ret void
}

LLVM IR (-O2):
@.str = [46 x i8] c"\0A// Integer types (we assume int >= 32 bits)\0A\00"
@.str.1 = [49 x i8] c"typedef char int8;\0Atypedef unsigned char uint8;\0A\00"
@.str.2 = [53 x i8] c"typedef short int16;\0Atypedef unsigned short uint16;\0A\00"
@.str.3 = [49 x i8] c"typedef int int32;\0Atypedef unsigned int uint32;\0A\00"
@.str.4 = [51 x i8] c"typedef long int64;\0Atypedef unsigned long uint64;\0A\00"
@.str.5 = [41 x i8] c"int main() { off64_t a = 1; return 0; }\0A\00"
@.str.6 = [24 x i8] c"typedef int64 off64_t;\0A\00"
define void @get_integer_typedefs(i32* nocapture %0) {
%2 = tail call i64 @fwrite(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i64 45, i64 1, i32* %0)
%3 = tail call i64 @fwrite(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), i64 48, i64 1, i32* %0)
%4 = tail call i64 @fwrite(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.2, i64 0, i64 0), i64 52, i64 1, i32* %0)
%5 = tail call i64 @fwrite(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.3, i64 0, i64 0), i64 48, i64 1, i32* %0)
%6 = tail call i64 @fwrite(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.4, i64 0, i64 0), i64 50, i64 1, i32* %0)
%7 = tail call i64 @compiles_and_runs(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0), i32 0)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = tail call i64 @fwrite(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), i64 23, i64 1, i32* %0)
br label %11
11: ; preds = %9, %1
ret void
}