#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 */
scalar_t__ detect_mirror(char *);
scalar_t__ get_mirror_tag(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  char device[50];
  char tag[25];
  if (detect_mirror(device) != 0) {
    printf("Unable to detect Mir:ror device...\n");
    return (-1);
  }
  if (get_mirror_tag(tag, device) != 0) {
    printf("Failed to read Mir:ror device %s...\n", device);
    return (-1);
  }
  printf("%s\n", tag);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x40(%rbp),%rdi
call   1050 <detect_mirror@plt>
cmp    $0x0,%rax
je     116c <main+0x3c>
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ba <main+0x8a>
lea    -0x60(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1030 <get_mirror_tag@plt>
cmp    $0x0,%rax
je     11a1 <main+0x71>
lea    -0x40(%rbp),%rsi
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ba <main+0x8a>
lea    -0x60(%rbp),%rsi
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x58,%rsp
lea    0x20(%rsp),%rdi
call   1060 <detect_mirror@plt>
test   %rax,%rax
je     1161 <main+0x21>
lea    0xecb(%rip),%rdi
call   1040 <puts@plt>
jmp    1186 <main+0x46>
mov    %rsp,%rdi
lea    0x20(%rsp),%rsi
call   1030 <get_mirror_tag@plt>
test   %rax,%rax
je     1190 <main+0x50>
lea    0xe86(%rip),%rdi
lea    0x20(%rsp),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xffffffff,%eax
add    $0x58,%rsp
ret
mov    %rsp,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x58,%rsp
ret

LLVM IR (-O0):
@.str = [36 x i8] c"Unable to detect Mir:ror device...\0A\00"
@.str.1 = [37 x i8] c"Failed to read Mir:ror device %s...\0A\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [50 x i8]
%3 = alloca [25 x i8]
store i32 0, i32* %1
%4 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%5 = call i64 @detect_mirror(i8* %4)
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %1
br label %20
9: ; preds = %0
%10 = getelementptr inbounds [25 x i8], [25 x i8]* %3, i64 0, i64 0
%11 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%12 = call i64 @get_mirror_tag(i8* %10, i8* %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %9
%15 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %15)
store i32 -1, i32* %1
br label %20
17: ; preds = %9
%18 = getelementptr inbounds [25 x i8], [25 x i8]* %3, i64 0, i64 0
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %18)
store i32 0, i32* %1
br label %20
20: ; preds = %17, %14, %7
%21 = load i32, i32* %1
ret i32 %21
}

LLVM IR (-O2):
@.str.1 = [37 x i8] c"Failed to read Mir:ror device %s...\0A\00"
@str = [35 x i8] c"Unable to detect Mir:ror device...\00"
define i32 @main() {
%1 = alloca [50 x i8]
%2 = alloca [25 x i8]
%3 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [25 x i8], [25 x i8]* %2, i64 0, i64 0
%5 = call i64 @detect_mirror(i8* %3)
%6 = icmp eq i64 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %0
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
br label %16
9: ; preds = %0
%10 = call i64 @get_mirror_tag(i8* %4, i8* %3)
%11 = icmp eq i64 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %9
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %3)
br label %16
14: ; preds = %9
%15 = call i32 @puts(i8* %4)
br label %16
16: ; preds = %14, %12, %7
%17 = phi i32 [ -1, %7 ], [ -1, %12 ], [ 0, %14 ]
ret i32 %17
}