#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*/ matrix_deinit();
scalar_t__ matrix_init();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ socket_deinit();
scalar_t__ socket_handle();
scalar_t__ socket_init();
int main(void) {
  if (matrix_init() < 0) {
    printf("Unable to open Matrix\r\n");
    return -1;
  } else {
    if (socket_init() < 0) {
      printf("Unable to open socket\r\n");
      return -1;
    } else {
      while (socket_handle() >= 0)
        ;
      socket_deinit();
    }
    matrix_deinit();
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1060 <matrix_init@plt>
cmp    $0x0,%rax
jge    1198 <main+0x38>
lea    0xe79(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f1 <main+0x91>
mov    $0x0,%al
call   1050 <socket_init@plt>
cmp    $0x0,%rax
jge    11c1 <main+0x61>
lea    0xe68(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f1 <main+0x91>
jmp    11c6 <main+0x66>
mov    $0x0,%al
call   1080 <socket_handle@plt>
cmp    $0x0,%rax
jl     11dc <main+0x7c>
jmp    11c6 <main+0x66>
mov    $0x0,%al
call   1030 <socket_deinit@plt>
mov    $0x0,%al
call   1070 <matrix_deinit@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1060 <matrix_init@plt>
test   %rax,%rax
js     119e <main+0x3e>
xor    %eax,%eax
call   1050 <socket_init@plt>
test   %rax,%rax
js     11a7 <main+0x47>
nopl   0x0(%rax)
xor    %eax,%eax
call   1080 <socket_handle@plt>
test   %rax,%rax
jns    1180 <main+0x20>
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <socket_deinit@plt>
xor    %eax,%eax
call   1070 <matrix_deinit@plt>
jmp    11b8 <main+0x58>
lea    0xe72(%rip),%rdi
jmp    11ae <main+0x4e>
lea    0xe52(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [24 x i8] c"Unable to open Matrix\0D\0A\00"
@.str.1 = [24 x i8] c"Unable to open socket\0D\0A\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i64 (...) @matrix_init()
%3 = icmp slt i64 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %1
br label %21
6: ; preds = %0
%7 = call i64 (...) @socket_init()
%8 = icmp slt i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %1
br label %21
11: ; preds = %6
br label %12
12: ; preds = %15, %11
%13 = call i64 (...) @socket_handle()
%14 = icmp sge i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %12
br label %12
16: ; preds = %12
%17 = call i32 (...) @socket_deinit()
br label %18
18: ; preds = %16
%19 = call i32 (...) @matrix_deinit()
br label %20
20: ; preds = %18
store i32 0, i32* %1
br label %21
21: ; preds = %20, %9, %4
%22 = load i32, i32* %1
ret i32 %22
}

LLVM IR (-O2):
@str = [23 x i8] c"Unable to open socket\0D\00"
@str.2 = [23 x i8] c"Unable to open Matrix\0D\00"
define i32 @main() {
%1 = tail call i64 (...) @matrix_init()
%2 = icmp slt i64 %1, 0
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.2, i64 0, i64 0))
br label %16
5: ; preds = %0
%6 = tail call i64 (...) @socket_init()
%7 = icmp slt i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
br label %16
10: ; preds = %5, %10
%11 = tail call i64 (...) @socket_handle()
%12 = icmp sgt i64 %11, -1
br i1 %12, label %10, label %13
13: ; preds = %10
%14 = tail call i32 (...) @socket_deinit()
%15 = tail call i32 (...) @matrix_deinit()
br label %16
16: ; preds = %13, %8, %3
%17 = phi i32 [ -1, %3 ], [ -1, %8 ], [ 0, %13 ]
ret i32 %17
}