#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 uint8_t;
typedef int /*<<< orphan*/ uint64_t;
typedef int /*<<< orphan*/ uint32_t;
typedef int uint16_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ check_size_(int, int, char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ put_string(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  FILE *config;
  uint16_t two_byte_int;
  uint8_t *byte_array;
  check_size_(sizeof(uint8_t), (1), "uint8_t");
  check_size_(sizeof(uint16_t), (2), "uint16_t");
  check_size_(sizeof(uint32_t), (4), "uint32_t");
  check_size_(sizeof(uint64_t), (8), "uint64_t");
  config = fopen("config.h", "w");
  if (config == NULL) {
    fprintf(stderr, "Failed to open config.h\n");
    exit(EXIT_FAILURE);
  }
  put_string(config, "/* config.h: generated by configure.c */\n\n");
  two_byte_int = 1;
  byte_array = (void *)&two_byte_int;
  if (byte_array[0] == 0x01) {
    put_string(config, "#define ENDIAN_LITTLE\n");
  } else {
    put_string(config, "#define ENDIAN_BIG\n");
  }
  fclose(config);
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x4,%edi
mov    $0x1,%esi
lea    0xe79(%rip),%rdx
call   1040 <check_size_@plt>
mov    $0x4,%edi
mov    $0x2,%esi
lea    0xe6b(%rip),%rdx
call   1040 <check_size_@plt>
mov    $0x4,%esi
lea    0xe63(%rip),%rdx
mov    %esi,%edi
call   1040 <check_size_@plt>
mov    $0x4,%edi
mov    $0x8,%esi
lea    0xe54(%rip),%rdx
call   1040 <check_size_@plt>
lea    0xe51(%rip),%rdi
lea    0xe53(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1210 <main+0xb0>
mov    0x2dec(%rip),%rax
mov    (%rax),%edi
lea    0xe31(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2dcf(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x18(%rbp),%rdi
lea    0xe2c(%rip),%rsi
call   1060 <put_string@plt>
movl   $0x1,-0x1c(%rbp)
lea    -0x1c(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmpl   $0x1,(%rax)
jne    1251 <main+0xf1>
mov    -0x18(%rbp),%rdi
lea    0xe2b(%rip),%rsi
call   1060 <put_string@plt>
jmp    1261 <main+0x101>
mov    -0x18(%rbp),%rdi
lea    0xe2d(%rip),%rsi
call   1060 <put_string@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    0x2d5f(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xe98(%rip),%rdx
mov    $0x4,%edi
mov    $0x1,%esi
call   1040 <check_size_@plt>
lea    0xe8a(%rip),%rdx
mov    $0x4,%edi
mov    $0x2,%esi
call   1040 <check_size_@plt>
lea    0xe7d(%rip),%rdx
mov    $0x4,%edi
mov    $0x4,%esi
call   1040 <check_size_@plt>
lea    0xe70(%rip),%rdx
mov    $0x4,%edi
mov    $0x8,%esi
call   1040 <check_size_@plt>
lea    0xe63(%rip),%rdi
lea    0xe65(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
jne    11f4 <main+0x94>
mov    0x2e08(%rip),%rax
mov    (%rax),%edi
lea    0xe4d(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2deb(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    %rax,%rbx
lea    0xe49(%rip),%rsi
mov    %rax,%rdi
call   1060 <put_string@plt>
lea    0xe65(%rip),%rsi
mov    %rbx,%rdi
call   1060 <put_string@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    0x2dac(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"uint8_t\00"
@.str.1 = [9 x i8] c"uint16_t\00"
@.str.2 = [9 x i8] c"uint32_t\00"
@.str.3 = [9 x i8] c"uint64_t\00"
@.str.4 = [9 x i8] c"config.h\00"
@.str.5 = [2 x i8] c"w\00"
@stderr = global i32 0
@.str.6 = [25 x i8] c"Failed to open config.h\0A\00"
@EXIT_FAILURE = global i32 0
@.str.7 = [43 x i8] c"/* config.h: generated by configure.c */\0A\0A\00"
@.str.8 = [23 x i8] c"#define ENDIAN_LITTLE\0A\00"
@.str.9 = [20 x i8] c"#define ENDIAN_BIG\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 @check_size_(i32 4, i32 1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @check_size_(i32 4, i32 2, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @check_size_(i32 4, i32 4, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @check_size_(i32 4, i32 8, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %13, i32** %6
%14 = load i32*, i32** %6
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %21
16: ; preds = %2
%17 = load i32, i32* @stderr
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0))
%19 = load i32, i32* @EXIT_FAILURE
%20 = call i32 @exit(i32 %19)
unreachable
21: ; preds = %2
%22 = load i32*, i32** %6
%23 = call i32 @put_string(i32* %22, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.7, i64 0, i64 0))
store i32 1, i32* %7
%24 = bitcast i32* %7 to i8*
%25 = bitcast i8* %24 to i32*
store i32* %25, i32** %8
%26 = load i32*, i32** %8
%27 = getelementptr inbounds i32, i32* %26, i64 0
%28 = load i32, i32* %27
%29 = icmp eq i32 %28, 1
br i1 %29, label %30, label %33
30: ; preds = %21
%31 = load i32*, i32** %6
%32 = call i32 @put_string(i32* %31, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0))
br label %36
33: ; preds = %21
%34 = load i32*, i32** %6
%35 = call i32 @put_string(i32* %34, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0))
br label %36
36: ; preds = %33, %30
%37 = load i32*, i32** %6
%38 = call i32 @fclose(i32* %37)
%39 = load i32, i32* @EXIT_SUCCESS
%40 = call i32 @exit(i32 %39)
unreachable
}

LLVM IR (-O2):
@.str = [8 x i8] c"uint8_t\00"
@.str.1 = [9 x i8] c"uint16_t\00"
@.str.2 = [9 x i8] c"uint32_t\00"
@.str.3 = [9 x i8] c"uint64_t\00"
@.str.4 = [9 x i8] c"config.h\00"
@.str.5 = [2 x i8] c"w\00"
@stderr = global i32 0
@.str.6 = [25 x i8] c"Failed to open config.h\0A\00"
@EXIT_FAILURE = global i32 0
@.str.7 = [43 x i8] c"/* config.h: generated by configure.c */\0A\0A\00"
@.str.8 = [23 x i8] c"#define ENDIAN_LITTLE\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @check_size_(i32 4, i32 1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @check_size_(i32 4, i32 2, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 @check_size_(i32 4, i32 4, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%6 = tail call i32 @check_size_(i32 4, i32 8, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%7 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %14
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0))
%12 = load i32, i32* @EXIT_FAILURE
%13 = tail call i32 @exit(i32 %12)
unreachable
14: ; preds = %2
%15 = tail call i32 @put_string(i32* %7, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.7, i64 0, i64 0))
%16 = tail call i32 @put_string(i32* %7, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0))
%17 = tail call i32 @fclose(i32* %7)
%18 = load i32, i32* @EXIT_SUCCESS
%19 = tail call i32 @exit(i32 %18)
unreachable
}