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

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int get_display_type(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
bool show_display_type(void) {
  char type[32];
  int res = get_display_type(type, sizeof(type));
  if (res < 0) {
    fprintf(stderr, "ERROR: Cannot determine display type\n");
    return false;
  }
  if (0 == strcmp("INVALID", type)) {
    printf("Display device is not responding (turned off?)\n");
    return false;
  }
  printf("Display device uses %s connector\n", type);
  return true;
}


x86 assembly (clang, -O0):
<show_display_type>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
lea    -0x30(%rbp),%rdi
mov    $0x20,%esi
call   1060 <get_display_type@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jge    1184 <show_display_type+0x44>
mov    0x2e76(%rip),%rax
mov    (%rax),%edi
lea    0xe8d(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11d5 <show_display_type+0x95>
lea    -0x30(%rbp),%rsi
lea    0xe97(%rip),%rdi
call   1040 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    11bc <show_display_type+0x7c>
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11d5 <show_display_type+0x95>
lea    -0x30(%rbp),%rsi
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_display_type>:
sub    $0x28,%rsp
mov    %rsp,%rdi
mov    $0x20,%esi
call   1070 <get_display_type@plt>
test   %eax,%eax
js     1194 <show_display_type+0x44>
lea    0xeba(%rip),%rdi
mov    %rsp,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11ab <show_display_type+0x5b>
lea    0xeae(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%eax
add    $0x28,%rsp
ret
mov    0x2e45(%rip),%rax
mov    (%rax),%edi
lea    0xe5c(%rip),%rsi
call   1060 <fprintf@plt>
jmp    11b7 <show_display_type+0x67>
lea    0xe9e(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [38 x i8] c"ERROR: Cannot determine display type\0A\00"
@.str.1 = [8 x i8] c"INVALID\00"
@.str.2 = [48 x i8] c"Display device is not responding (turned off?)\0A\00"
@.str.3 = [34 x i8] c"Display device uses %s connector\0A\00"
define i32 @show_display_type() {
%1 = alloca i32
%2 = alloca [32 x i8]
%3 = alloca i32
%4 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%5 = call i32 @get_display_type(i8* %4, i32 32)
store i32 %5, i32* %3
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = load i32, i32* @stderr
%10 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %1
br label %20
11: ; preds = %0
%12 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%13 = call i64 @strcmp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = icmp eq i64 0, %13
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %20
17: ; preds = %11
%18 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i8* %18)
store i32 1, i32* %1
br label %20
20: ; preds = %17, %15, %8
%21 = load i32, i32* %1
ret i32 %21
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [38 x i8] c"ERROR: Cannot determine display type\0A\00"
@.str.1 = [8 x i8] c"INVALID\00"
@.str.3 = [34 x i8] c"Display device uses %s connector\0A\00"
@str = [47 x i8] c"Display device is not responding (turned off?)\00"
define i32 @show_display_type() {
%1 = alloca [32 x i8]
%2 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 0
%3 = call i32 @get_display_type(i8* %2, i32 32)
%4 = icmp slt i32 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %0
%6 = load i32, i32* @stderr
%7 = call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
br label %15
8: ; preds = %0
%9 = call i64 @strcmp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str, i64 0, i64 0))
br label %15
13: ; preds = %8
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i8* %2)
br label %15
15: ; preds = %13, %11, %5
%16 = phi i32 [ 0, %5 ], [ 0, %11 ], [ 1, %13 ]
ret i32 %16
}