#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ addr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ IPPROTO_TCP;
int /*<<< orphan*/ SOCK_STREAM;
int accept(int, struct sockaddr *, int *);
int bind(int, struct sockaddr *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ execvp(char *, char **);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
char *getenv(char *);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ inet_addr(char *);
int listen(int, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ puts(char *);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  if (argc > 1 && 0 == strcmp(argv[1], "--stop-hammer-time")) {
    int fd, afd;
    char *debug = getenv("DOCKERLITE_DEBUG");
    struct sockaddr_in addr;
    socklen_t len = sizeof(addr);
    if (debug)
      puts("dockerlite: Stopped. Waiting for signal to resume.");
    fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
    addr.sin_family = AF_INET;
    addr.sin_port = htons(9);
    addr.sin_addr.s_addr = inet_addr("127.0.0.1");
    if (-1 == bind(fd, (struct sockaddr *)&addr, sizeof(addr))) {
      perror("bind");
    } else {
      if (-1 == listen(fd, 1)) {
        perror("listen");
      } else {
        afd = accept(fd, (struct sockaddr *)&addr, &len);
        if (-1 == afd) {
          perror("accept");
        }
        close(afd);
      }
    }
    close(fd);
    if (debug)
      puts("dockerlite: Got signal. Resuming.");
    execvp(argv[2], argv + 2);
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1357 <main+0x187>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe01(%rip),%rsi
call   1080 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1357 <main+0x187>
lea    0xdfa(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x20(%rbp)
movl   $0xc,-0x34(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1240 <main+0x70>
lea    0xde9(%rip),%rdi
call   1040 <puts@plt>
mov    0x2da1(%rip),%rax
mov    (%rax),%edi
mov    0x2d80(%rip),%rax
mov    (%rax),%esi
mov    0x2d87(%rip),%rax
mov    (%rax),%edx
call   10f0 <socket@plt>
mov    %eax,-0x14(%rbp)
mov    0x2d7e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    $0x9,%edi
call   1050 <htons@plt>
mov    %eax,-0x2c(%rbp)
lea    0xdd4(%rip),%rdi
call   1070 <inet_addr@plt>
mov    %eax,-0x30(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    $0xc,%edx
call   10a0 <bind@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    12bc <main+0xec>
lea    0xdaf(%rip),%rdi
call   10b0 <perror@plt>
jmp    1323 <main+0x153>
mov    -0x14(%rbp),%edi
mov    $0x1,%esi
call   1090 <listen@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    12e9 <main+0x119>
lea    0xd87(%rip),%rdi
call   10b0 <perror@plt>
jmp    131e <main+0x14e>
mov    -0x14(%rbp),%edi
lea    -0x30(%rbp),%rsi
lea    -0x34(%rbp),%rdx
call   10c0 <accept@plt>
mov    %eax,-0x18(%rbp)
mov    $0xffffffff,%eax
cmp    -0x18(%rbp),%eax
jne    1316 <main+0x146>
lea    0xd5c(%rip),%rdi
call   10b0 <perror@plt>
mov    -0x18(%rbp),%edi
call   1060 <close@plt>
jmp    1323 <main+0x153>
mov    -0x14(%rbp),%edi
call   1060 <close@plt>
cmpq   $0x0,-0x20(%rbp)
je     1342 <main+0x172>
lea    0xd37(%rip),%rdi
call   1040 <puts@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x10(%rbp),%rsi
add    $0x10,%rsi
call   10d0 <execvp@plt>
xor    %edi,%edi
call   10e0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
cmp    $0x2,%edi
jl     12d9 <main+0x109>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe0d(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
jne    12d9 <main+0x109>
lea    0xe0b(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%r14
movl   $0xc,0xc(%rsp)
test   %rax,%rax
je     1229 <main+0x59>
lea    0xe00(%rip),%rdi
call   1040 <puts@plt>
mov    0x2db8(%rip),%rbp
mov    0x0(%rbp),%edi
mov    0x2d96(%rip),%rax
mov    (%rax),%esi
mov    0x2d9d(%rip),%rax
mov    (%rax),%edx
call   10f0 <socket@plt>
mov    %eax,%r12d
mov    0x0(%rbp),%eax
mov    %eax,0x18(%rsp)
mov    $0x9,%edi
call   1050 <htons@plt>
mov    %eax,0x14(%rsp)
lea    0xdee(%rip),%rdi
call   1070 <inet_addr@plt>
mov    %eax,0x10(%rsp)
lea    0x10(%rsp),%rsi
mov    %r12d,%edi
mov    $0xc,%edx
call   10a0 <bind@plt>
cmp    $0xffffffff,%eax
jne    1292 <main+0xc2>
lea    0xdd1(%rip),%rdi
jmp    12ab <main+0xdb>
mov    %r12d,%edi
mov    $0x1,%esi
call   1090 <listen@plt>
cmp    $0xffffffff,%eax
jne    12e0 <main+0x110>
lea    0xdbb(%rip),%rdi
call   10b0 <perror@plt>
mov    %r12d,%edi
call   1060 <close@plt>
test   %r14,%r14
je     12c9 <main+0xf9>
lea    0xdb0(%rip),%rdi
call   1040 <puts@plt>
mov    0x10(%rbx),%rdi
add    $0x10,%rbx
mov    %rbx,%rsi
call   10d0 <execvp@plt>
xor    %edi,%edi
call   10e0 <exit@plt>
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
mov    %r12d,%edi
call   10c0 <accept@plt>
mov    %eax,%r15d
cmp    $0xffffffff,%eax
jne    1306 <main+0x136>
lea    0xd6c(%rip),%rdi
call   10b0 <perror@plt>
mov    %r15d,%edi
call   1060 <close@plt>
jmp    12b0 <main+0xe0>

LLVM IR (-O0):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [19 x i8] c"--stop-hammer-time\00"
@.str.1 = [17 x i8] c"DOCKERLITE_DEBUG\00"
@.str.2 = [51 x i8] c"dockerlite: Stopped. Waiting for signal to resume.\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@IPPROTO_TCP = global i32 0
@.str.3 = [10 x i8] c"127.0.0.1\00"
@.str.4 = [5 x i8] c"bind\00"
@.str.5 = [7 x i8] c"listen\00"
@.str.6 = [7 x i8] c"accept\00"
@.str.7 = [34 x i8] c"dockerlite: Got signal. Resuming.\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca %struct.sockaddr_in
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp sgt i32 %11, 1
br i1 %12, label %13, label %75
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%18 = icmp eq i64 0, %17
br i1 %18, label %19, label %75
19: ; preds = %13
%20 = call i8* @getenv(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
store i8* %20, i8** %8
store i32 12, i32* %10
%21 = load i8*, i8** %8
%22 = icmp ne i8* %21, null
br i1 %22, label %23, label %25
23: ; preds = %19
%24 = call i32 @puts(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0))
br label %25
25: ; preds = %23, %19
%26 = load i32, i32* @AF_INET
%27 = load i32, i32* @SOCK_STREAM
%28 = load i32, i32* @IPPROTO_TCP
%29 = call i32 @socket(i32 %26, i32 %27, i32 %28)
store i32 %29, i32* %6
%30 = load i32, i32* @AF_INET
%31 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 2
store i32 %30, i32* %31
%32 = call i32 @htons(i32 9)
%33 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 1
store i32 %32, i32* %33
%34 = call i32 @inet_addr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%35 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 0
%36 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %35, i32 0, i32 0
store i32 %34, i32* %36
%37 = load i32, i32* %6
%38 = bitcast %struct.sockaddr_in* %9 to %struct.sockaddr*
%39 = call i32 @bind(i32 %37, %struct.sockaddr* %38, i32 12)
%40 = icmp eq i32 -1, %39
br i1 %40, label %41, label %43
41: ; preds = %25
%42 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %61
43: ; preds = %25
%44 = load i32, i32* %6
%45 = call i32 @listen(i32 %44, i32 1)
%46 = icmp eq i32 -1, %45
br i1 %46, label %47, label %49
47: ; preds = %43
%48 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
br label %60
49: ; preds = %43
%50 = load i32, i32* %6
%51 = bitcast %struct.sockaddr_in* %9 to %struct.sockaddr*
%52 = call i32 @accept(i32 %50, %struct.sockaddr* %51, i32* %10)
store i32 %52, i32* %7
%53 = load i32, i32* %7
%54 = icmp eq i32 -1, %53
br i1 %54, label %55, label %57
55: ; preds = %49
%56 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
br label %57
57: ; preds = %55, %49
%58 = load i32, i32* %7
%59 = call i32 @close(i32 %58)
br label %60
60: ; preds = %57, %47
br label %61
61: ; preds = %60, %41
%62 = load i32, i32* %6
%63 = call i32 @close(i32 %62)
%64 = load i8*, i8** %8
%65 = icmp ne i8* %64, null
br i1 %65, label %66, label %68
66: ; preds = %61
%67 = call i32 @puts(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.7, i64 0, i64 0))
br label %68
68: ; preds = %66, %61
%69 = load i8**, i8*** %5
%70 = getelementptr inbounds i8*, i8** %69, i64 2
%71 = load i8*, i8** %70
%72 = load i8**, i8*** %5
%73 = getelementptr inbounds i8*, i8** %72, i64 2
%74 = call i32 @execvp(i8* %71, i8** %73)
br label %75
75: ; preds = %68, %13, %2
%76 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [19 x i8] c"--stop-hammer-time\00"
@.str.1 = [17 x i8] c"DOCKERLITE_DEBUG\00"
@.str.2 = [51 x i8] c"dockerlite: Stopped. Waiting for signal to resume.\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@IPPROTO_TCP = global i32 0
@.str.3 = [10 x i8] c"127.0.0.1\00"
@.str.4 = [5 x i8] c"bind\00"
@.str.5 = [7 x i8] c"listen\00"
@.str.6 = [7 x i8] c"accept\00"
@.str.7 = [34 x i8] c"dockerlite: Got signal. Resuming.\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca i32
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %54
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %54
11: ; preds = %6
%12 = tail call i8* @getenv(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%13 = bitcast %struct.sockaddr_in* %3 to i8*
%14 = bitcast i32* %4 to i8*
store i32 12, i32* %4
%15 = icmp eq i8* %12, null
br i1 %15, label %18, label %16
16: ; preds = %11
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0))
br label %18
18: ; preds = %16, %11
%19 = load i32, i32* @AF_INET
%20 = load i32, i32* @SOCK_STREAM
%21 = load i32, i32* @IPPROTO_TCP
%22 = tail call i32 @socket(i32 %19, i32 %20, i32 %21)
%23 = load i32, i32* @AF_INET
%24 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %23, i32* %24
%25 = tail call i32 @htons(i32 9)
%26 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1
store i32 %25, i32* %26
%27 = tail call i32 @inet_addr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%28 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0, i32 0
store i32 %27, i32* %28
%29 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%30 = call i32 @bind(i32 %22, %struct.sockaddr* %29, i32 12)
%31 = icmp eq i32 %30, -1
br i1 %31, label %32, label %34
32: ; preds = %18
%33 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %46
34: ; preds = %18
%35 = call i32 @listen(i32 %22, i32 1)
%36 = icmp eq i32 %35, -1
br i1 %36, label %37, label %39
37: ; preds = %34
%38 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
br label %46
39: ; preds = %34
%40 = call i32 @accept(i32 %22, %struct.sockaddr* %29, i32* %4)
%41 = icmp eq i32 %40, -1
br i1 %41, label %42, label %44
42: ; preds = %39
%43 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
br label %44
44: ; preds = %42, %39
%45 = call i32 @close(i32 %40)
br label %46
46: ; preds = %37, %44, %32
%47 = call i32 @close(i32 %22)
br i1 %15, label %50, label %48
48: ; preds = %46
%49 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.7, i64 0, i64 0))
br label %50
50: ; preds = %48, %46
%51 = getelementptr inbounds i8*, i8** %1, i64 2
%52 = load i8*, i8** %51
%53 = call i32 @execvp(i8* %52, i8** %51)
br label %54
54: ; preds = %50, %6, %2
%55 = call i32 @exit(i32 0)
unreachable
}