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

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int get_hotplug();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
bool show_hotplug(void) {
  int plugged_in = get_hotplug();
  if (plugged_in < 0) {
    fprintf(stderr,
            "ERROR: Cannot determine connection status of display device\n");
    return false;
  }
  if (plugged_in) {
    printf("Display device is connected\n");
  } else {
    printf("Display device is NOT connected\n");
  }
  return plugged_in;
}


x86 assembly (clang, -O0):
<show_hotplug>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1050 <get_hotplug@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    116d <show_hotplug+0x3d>
mov    0x2e8d(%rip),%rax
mov    (%rax),%edi
lea    0xea4(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    119a <show_hotplug+0x6a>
cmpl   $0x0,-0x8(%rbp)
je     1188 <show_hotplug+0x58>
lea    0xebf(%rip),%rdi
call   1030 <printf@plt>
jmp    1194 <show_hotplug+0x64>
lea    0xecb(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_hotplug>:
push   %rbp
push   %rbx
push   %rax
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <get_hotplug@plt>
test   %eax,%eax
js     1154 <show_hotplug+0x24>
je     116b <show_hotplug+0x3b>
mov    %eax,%ebp
lea    0xf12(%rip),%rdi
call   1030 <puts@plt>
mov    %ebp,%ebx
jmp    1179 <show_hotplug+0x49>
mov    0x2e85(%rip),%rax
mov    (%rax),%edi
lea    0xe9c(%rip),%rsi
call   1040 <fprintf@plt>
jmp    1179 <show_hotplug+0x49>
lea    0xecb(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [61 x i8] c"ERROR: Cannot determine connection status of display device\0A\00"
@.str.1 = [29 x i8] c"Display device is connected\0A\00"
@.str.2 = [33 x i8] c"Display device is NOT connected\0A\00"
define i32 @show_hotplug() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 (...) @get_hotplug()
store i32 %3, i32* %2
%4 = load i32, i32* %2
%5 = icmp slt i32 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %0
%7 = load i32, i32* @stderr
%8 = call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %1
br label %18
9: ; preds = %0
%10 = load i32, i32* %2
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
br label %16
14: ; preds = %9
%15 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
br label %16
16: ; preds = %14, %12
%17 = load i32, i32* %2
store i32 %17, i32* %1
br label %18
18: ; preds = %16, %6
%19 = load i32, i32* %1
ret i32 %19
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [61 x i8] c"ERROR: Cannot determine connection status of display device\0A\00"
@str = [32 x i8] c"Display device is NOT connected\00"
@str.3 = [28 x i8] c"Display device is connected\00"
define i32 @show_hotplug() {
%1 = tail call i32 (...) @get_hotplug()
%2 = icmp slt i32 %1, 0
br i1 %2, label %3, label %6
3: ; preds = %0
%4 = load i32, i32* @stderr
%5 = tail call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0))
br label %12
6: ; preds = %0
%7 = icmp eq i32 %1, 0
br i1 %7, label %10, label %8
8: ; preds = %6
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.3, i64 0, i64 0))
br label %12
10: ; preds = %6
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
br label %12
12: ; preds = %8, %10, %3
%13 = phi i32 [ 0, %3 ], [ 0, %10 ], [ %1, %8 ]
ret i32 %13
}