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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
char *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ memset(char *, int, int);
int /*<<< orphan*/ printf(char *, char *);
int show_model(void) {
  FILE *fp = NULL;
  char buffer[256];
  char *pbuf = NULL;
  fp = fopen("/proc/device-tree/model", "r");
  if (fp != NULL) {
    while (!feof(fp)) {
      memset(buffer, 0x00, sizeof(buffer));
      pbuf = fgets(buffer, sizeof(buffer), fp);
      if (pbuf != NULL) {
        printf("Model           : %s\n", pbuf);
      }
    }
    fclose(fp);
    fp = NULL;
  }
  return 0;
}


x86 assembly (clang, -O0):
<show_model>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movq   $0x0,-0x8(%rbp)
movq   $0x0,-0x118(%rbp)
lea    0xe7b(%rip),%rdi
lea    0xe8c(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1229 <show_model+0xc9>
jmp    11a5 <show_model+0x45>
mov    -0x8(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11c3 <show_model+0x63>
jmp    1218 <show_model+0xb8>
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1050 <memset@plt>
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x100,%esi
call   1060 <fgets@plt>
mov    %rax,-0x118(%rbp)
cmpq   $0x0,-0x118(%rbp)
je     1213 <show_model+0xb3>
mov    -0x118(%rbp),%rsi
lea    0xe0c(%rip),%rdi
call   1040 <printf@plt>
jmp    11a5 <show_model+0x45>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
movq   $0x0,-0x8(%rbp)
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_model>:
push   %r15
push   %r14
push   %rbx
sub    $0x100,%rsp
lea    0xe8d(%rip),%rdi
lea    0xe9e(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     119b <show_model+0x3b>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <feof@plt>
test   %eax,%eax
je     11aa <show_model+0x4a>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
mov    %rsp,%r14
lea    0xe66(%rip),%r15
jmp    11cc <show_model+0x6c>
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1070 <feof@plt>
test   %eax,%eax
jne    1193 <show_model+0x33>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1050 <memset@plt>
mov    %r14,%rdi
mov    $0x100,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     11c0 <show_model+0x60>
mov    %r15,%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
jmp    11c0 <show_model+0x60>

LLVM IR (-O0):
@.str = [24 x i8] c"/proc/device-tree/model\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [22 x i8] c"Model : %s\0A\00"
define i32 @show_model() {
%1 = alloca i32*
%2 = alloca [256 x i8]
%3 = alloca i8*
store i32* null, i32** %1
store i8* null, i8** %3
%4 = call i32* @fopen(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %4, i32** %1
%5 = load i32*, i32** %1
%6 = icmp ne i32* %5, null
br i1 %6, label %7, label %28
7: ; preds = %0
br label %8
8: ; preds = %24, %7
%9 = load i32*, i32** %1
%10 = call i32 @feof(i32* %9)
%11 = icmp ne i32 %10, 0
%12 = xor i1 %11, true
br i1 %12, label %13, label %25
13: ; preds = %8
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%15 = call i32 @memset(i8* %14, i32 0, i32 256)
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%17 = load i32*, i32** %1
%18 = call i8* @fgets(i8* %16, i32 256, i32* %17)
store i8* %18, i8** %3
%19 = load i8*, i8** %3
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %24
21: ; preds = %13
%22 = load i8*, i8** %3
%23 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %22)
br label %24
24: ; preds = %21, %13
br label %8
25: ; preds = %8
%26 = load i32*, i32** %1
%27 = call i32 @fclose(i32* %26)
store i32* null, i32** %1
br label %28
28: ; preds = %25, %0
ret i32 0
}

LLVM IR (-O2):
@.str = [24 x i8] c"/proc/device-tree/model\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [22 x i8] c"Model : %s\0A\00"
define i32 @show_model() {
%1 = alloca [256 x i8]
%2 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %19, label %5
5: ; preds = %0
%6 = call i32 @feof(i32* %3)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %17
8: ; preds = %5, %14
%9 = call i32 @memset(i8* %2, i32 0, i32 256)
%10 = call i8* @fgets(i8* %2, i32 256, i32* %3)
%11 = icmp eq i8* %10, null
br i1 %11, label %14, label %12
12: ; preds = %8
%13 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %10)
br label %14
14: ; preds = %12, %8
%15 = call i32 @feof(i32* %3)
%16 = icmp eq i32 %15, 0
br i1 %16, label %8, label %17
17: ; preds = %14, %5
%18 = call i32 @fclose(i32* %3)
br label %19
19: ; preds = %17, %0
ret i32 0
}