#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 */
struct stat {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ close(int);
int connect_server(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
scalar_t__ transport(int, int);
int main(int argc, char *argv[]) {
  int server;
  struct stat stat_buf;
  if (argc < 2) {
    fprintf(stderr, "usage: egg-helper socket_path\n");
    exit(1);
  }
  server = connect_server(argv[1]);
  while (1)
    if (transport(0, server) == 0 || transport(server, 1) == 0)
      break;
  close(server);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    118f <main+0x3f>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
lea    0xe80(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <connect_server@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
xor    %edi,%edi
call   1040 <transport@plt>
cmp    $0x0,%rax
je     11ca <main+0x7a>
mov    -0x14(%rbp),%edi
mov    $0x1,%esi
call   1040 <transport@plt>
cmp    $0x0,%rax
jne    11cf <main+0x7f>
jmp    11d4 <main+0x84>
jmp    119f <main+0x4f>
mov    -0x14(%rbp),%edi
call   1050 <close@plt>
xor    %edi,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x1,%edi
jg     1175 <main+0x25>
mov    0x2e83(%rip),%rax
mov    (%rax),%edi
lea    0xe9a(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    0x8(%rsi),%rdi
call   1030 <connect_server@plt>
mov    %eax,%ebx
xor    %edi,%edi
mov    %ebx,%esi
call   1040 <transport@plt>
test   %rax,%rax
je     119f <main+0x4f>
mov    %ebx,%edi
mov    $0x1,%esi
call   1040 <transport@plt>
test   %rax,%rax
jne    1180 <main+0x30>
mov    %ebx,%edi
call   1050 <close@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
@stderr = global i32 0
@.str = [31 x i8] c"usage: egg-helper socket_path\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %struct.stat
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @connect_server(i8* %17)
store i32 %18, i32* %6
br label %19
19: ; preds = %14, %28
%20 = load i32, i32* %6
%21 = call i64 @transport(i32 0, i32 %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %27, label %23
23: ; preds = %19
%24 = load i32, i32* %6
%25 = call i64 @transport(i32 %24, i32 1)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %23, %19
br label %29
28: ; preds = %23
br label %19
29: ; preds = %27
%30 = load i32, i32* %6
%31 = call i32 @close(i32 %30)
%32 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [31 x i8] c"usage: egg-helper socket_path\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @connect_server(i8* %10)
br label %12
12: ; preds = %15, %8
%13 = tail call i64 @transport(i32 0, i32 %11)
%14 = icmp eq i64 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %12
%16 = tail call i64 @transport(i32 %11, i32 1)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %12
18: ; preds = %12, %15
%19 = tail call i32 @close(i32 %11)
%20 = tail call i32 @exit(i32 0)
unreachable
}