#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 */
typedef scalar_t__ ssize_t;
typedef int /*<<< orphan*/ overflow;
typedef int /*<<< orphan*/ command4;
typedef int /*<<< orphan*/ command3;
typedef int /*<<< orphan*/ command2;
typedef int /*<<< orphan*/ command1;
typedef int /*<<< orphan*/ buf;
typedef int /*<<< orphan*/ bad_command;

/* Variables and functions */
int /*<<< orphan*/ close(int);
int connect_unix_socket(char const *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ printresponse(unsigned char *, scalar_t__);
scalar_t__ read(int, unsigned char *, int);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ write(int, char *, int);
int main(int argc, char **argv) {
  char command1[] = "\x01\x00urn:schemas-upnp-org:device:InternetGatewayDevice";
  char command2[] =
      "\x02\x00uuid:fc4ec57e-b051-11db-88f8-0060085db3f6::upnp:rootdevice";
  char command3[] = {0x03, 0x00};
  char command4[] = "\x04\x00test:test:test";
  char bad_command[] = {0xff, 0xff};
  char overflow[] = {0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
  int s;
  int i;
  unsigned char buf[2048];
  ssize_t n;
  const char *sockpath = "/var/run/minissdpd.sock";
  for (i = 0; i < argc - 1; i++) {
    if (0 == strcmp(argv[i], "-s"))
      sockpath = argv[++i];
  }
  command1[1] = sizeof(command1) - 3;
  command2[1] = sizeof(command2) - 3;
  command4[1] = sizeof(command4) - 3;
  s = connect_unix_socket(sockpath);
  write(s, command1, sizeof(command1) - 1);
  printf("Command written type=%u\n", (unsigned)command1[0]);
  ;
  n = read(s, buf, sizeof(buf));
  printf("Response received %d bytes\n", (int)n);
  printresponse(buf, n);
  if (n == 0) {
    close(s);
    s = connect_unix_socket(sockpath);
  }
  write(s, command2, sizeof(command2) - 1);
  printf("Command written type=%u\n", (unsigned)command2[0]);
  ;
  n = read(s, buf, sizeof(buf));
  printf("Response received %d bytes\n", (int)n);
  printresponse(buf, n);
  if (n == 0) {
    close(s);
    s = connect_unix_socket(sockpath);
  }
  write(s, command3, sizeof(command3));
  printf("Command written type=%u\n", (unsigned)command3[0]);
  ;
  n = read(s, buf, sizeof(buf));
  printf("Response received %d bytes\n", (int)n);
  printresponse(buf, n);
  if (n == 0) {
    close(s);
    s = connect_unix_socket(sockpath);
  }
  write(s, command4, sizeof(command4));
  printf("Command written type=%u\n", (unsigned)command4[0]);
  ;
  write(s, bad_command, sizeof(bad_command));
  printf("Command written type=%u\n", (unsigned)bad_command[0]);
  ;
  n = read(s, buf, sizeof(buf));
  printf("Response received %d bytes\n", (int)n);
  printresponse(buf, n);
  if (n == 0) {
    close(s);
    s = connect_unix_socket(sockpath);
  }
  write(s, overflow, sizeof(overflow));
  printf("Command written type=%u\n", (unsigned)overflow[0]);
  ;
  n = read(s, buf, sizeof(buf));
  printf("Response received %d bytes\n", (int)n);
  printresponse(buf, n);
  close(s);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x8e0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xe5c(%rip),%rsi
mov    $0x34,%edx
call   1090 <memcpy@plt>
lea    -0x90(%rbp),%rdi
lea    0xe84(%rip),%rsi
mov    $0x3d,%edx
call   1090 <memcpy@plt>
mov    0xec6(%rip),%ax
mov    %ax,-0x92(%rbp)
mov    0xea5(%rip),%rax
mov    %rax,-0xb0(%rbp)
mov    0xe9f(%rip),%rax
mov    %rax,-0xa8(%rbp)
mov    0xe9a(%rip),%al
mov    %al,-0xa0(%rbp)
mov    0xe8e(%rip),%ax
mov    %ax,-0xb2(%rbp)
mov    0xed4(%rip),%rax
mov    %rax,-0xba(%rbp)
lea    0xe76(%rip),%rax
mov    %rax,-0x8e0(%rbp)
movl   $0x0,-0xc4(%rbp)
mov    -0xc4(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    12a7 <main+0x127>
mov    -0x10(%rbp),%rax
movslq -0xc4(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe53(%rip),%rsi
call   1080 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    128e <main+0x10e>
mov    -0x10(%rbp),%rax
mov    -0xc4(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,-0xc4(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x8e0(%rbp)
jmp    1293 <main+0x113>
mov    -0xc4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc4(%rbp)
jmp    1230 <main+0xb0>
movb   $0x31,-0x4f(%rbp)
movb   $0x3a,-0x8f(%rbp)
movb   $0xe,-0xaf(%rbp)
mov    -0x8e0(%rbp),%rdi
call   1030 <connect_unix_socket@plt>
mov    %eax,-0xc0(%rbp)
mov    -0xc0(%rbp),%edi
lea    -0x50(%rbp),%rsi
mov    $0x33,%edx
call   1040 <write@plt>
movsbl -0x50(%rbp),%esi
lea    0xdc6(%rip),%rdi
call   1050 <printf@plt>
mov    -0xc0(%rbp),%edi
lea    -0x8d0(%rbp),%rsi
mov    $0x800,%edx
call   1070 <read@plt>
mov    %rax,-0x8d8(%rbp)
mov    -0x8d8(%rbp),%rax
mov    %eax,%esi
lea    0xdac(%rip),%rdi
call   1050 <printf@plt>
lea    -0x8d0(%rbp),%rdi
mov    -0x8d8(%rbp),%rsi
call   10a0 <printresponse@plt>
cmpq   $0x0,-0x8d8(%rbp)
jne    1360 <main+0x1e0>
mov    -0xc0(%rbp),%edi
call   1060 <close@plt>
mov    -0x8e0(%rbp),%rdi
call   1030 <connect_unix_socket@plt>
mov    %eax,-0xc0(%rbp)
mov    -0xc0(%rbp),%edi
lea    -0x90(%rbp),%rsi
mov    $0x3c,%edx
call   1040 <write@plt>
movsbl -0x90(%rbp),%esi
lea    0xd2b(%rip),%rdi
call   1050 <printf@plt>
mov    -0xc0(%rbp),%edi
lea    -0x8d0(%rbp),%rsi
mov    $0x800,%edx
call   1070 <read@plt>
mov    %rax,-0x8d8(%rbp)
mov    -0x8d8(%rbp),%rax
mov    %eax,%esi
lea    0xd11(%rip),%rdi
call   1050 <printf@plt>
lea    -0x8d0(%rbp),%rdi
mov    -0x8d8(%rbp),%rsi
call   10a0 <printresponse@plt>
cmpq   $0x0,-0x8d8(%rbp)
jne    13fb <main+0x27b>
mov    -0xc0(%rbp),%edi
call   1060 <close@plt>
mov    -0x8e0(%rbp),%rdi
call   1030 <connect_unix_socket@plt>
mov    %eax,-0xc0(%rbp)
mov    -0xc0(%rbp),%edi
lea    -0x92(%rbp),%rsi
mov    $0x2,%edx
call   1040 <write@plt>
movsbl -0x92(%rbp),%esi
lea    0xc90(%rip),%rdi
call   1050 <printf@plt>
mov    -0xc0(%rbp),%edi
lea    -0x8d0(%rbp),%rsi
mov    $0x800,%edx
call   1070 <read@plt>
mov    %rax,-0x8d8(%rbp)
mov    -0x8d8(%rbp),%rax
mov    %eax,%esi
lea    0xc76(%rip),%rdi
call   1050 <printf@plt>
lea    -0x8d0(%rbp),%rdi
mov    -0x8d8(%rbp),%rsi
call   10a0 <printresponse@plt>
cmpq   $0x0,-0x8d8(%rbp)
jne    1496 <main+0x316>
mov    -0xc0(%rbp),%edi
call   1060 <close@plt>
mov    -0x8e0(%rbp),%rdi
call   1030 <connect_unix_socket@plt>
mov    %eax,-0xc0(%rbp)
mov    -0xc0(%rbp),%edi
lea    -0xb0(%rbp),%rsi
mov    $0x11,%edx
call   1040 <write@plt>
movsbl -0xb0(%rbp),%esi
lea    0xbf5(%rip),%rdi
call   1050 <printf@plt>
mov    -0xc0(%rbp),%edi
lea    -0xb2(%rbp),%rsi
mov    $0x2,%edx
call   1040 <write@plt>
movsbl -0xb2(%rbp),%esi
lea    0xbcb(%rip),%rdi
call   1050 <printf@plt>
mov    -0xc0(%rbp),%edi
lea    -0x8d0(%rbp),%rsi
mov    $0x800,%edx
call   1070 <read@plt>
mov    %rax,-0x8d8(%rbp)
mov    -0x8d8(%rbp),%rax
mov    %eax,%esi
lea    0xbb1(%rip),%rdi
call   1050 <printf@plt>
lea    -0x8d0(%rbp),%rdi
mov    -0x8d8(%rbp),%rsi
call   10a0 <printresponse@plt>
cmpq   $0x0,-0x8d8(%rbp)
jne    155b <main+0x3db>
mov    -0xc0(%rbp),%edi
call   1060 <close@plt>
mov    -0x8e0(%rbp),%rdi
call   1030 <connect_unix_socket@plt>
mov    %eax,-0xc0(%rbp)
mov    -0xc0(%rbp),%edi
lea    -0xba(%rbp),%rsi
mov    $0x8,%edx
call   1040 <write@plt>
movsbl -0xba(%rbp),%esi
lea    0xb30(%rip),%rdi
call   1050 <printf@plt>
mov    -0xc0(%rbp),%edi
lea    -0x8d0(%rbp),%rsi
mov    $0x800,%edx
call   1070 <read@plt>
mov    %rax,-0x8d8(%rbp)
mov    -0x8d8(%rbp),%rax
mov    %eax,%esi
lea    0xb16(%rip),%rdi
call   1050 <printf@plt>
lea    -0x8d0(%rbp),%rdi
mov    -0x8d8(%rbp),%rsi
call   10a0 <printresponse@plt>
mov    -0xc0(%rbp),%edi
call   1060 <close@plt>
xor    %eax,%eax
add    $0x8e0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x8b8,%rsp
movaps 0xe98(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xe7c(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xe60(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movl   $0x656369,0x60(%rsp)
movups 0xeb9(%rip),%xmm0
movups %xmm0,0x9d(%rsp)
movaps 0xe9d(%rip),%xmm0
movaps %xmm0,0x90(%rsp)
movaps 0xe7e(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
movaps 0xe5f(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movw   $0x3,0x6(%rsp)
movaps 0xe8c(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movb   $0x0,0x20(%rsp)
movw   $0xffff,0x4(%rsp)
movq   $0xffffffffffffff01,0x8(%rsp)
ff ff
cmp    $0x2,%edi
jl     1257 <main+0xe7>
mov    %rsi,%r13
mov    %edi,%r12d
add    $0xffffffff,%r12d
xor    %ebx,%ebx
lea    0xe6b(%rip),%r14
lea    0xe7c(%rip),%r15
jmp    1238 <main+0xc8>
nop
add    $0x1,%ebx
cmp    %r12d,%ebx
jge    125e <main+0xee>
movslq %ebx,%rbp
mov    0x0(%r13,%rbp,8),%rdi
mov    %r15,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
jne    1230 <main+0xc0>
lea    0x1(%rbp),%ebx
mov    0x8(%r13,%rbp,8),%r14
jmp    1230 <main+0xc0>
lea    0xe33(%rip),%r14
movb   $0x31,0x31(%rsp)
movb   $0x3a,0x71(%rsp)
movb   $0xe,0x11(%rsp)
mov    %r14,%rdi
call   1030 <connect_unix_socket@plt>
mov    %eax,%ebp
lea    0x30(%rsp),%rsi
mov    %eax,%edi
mov    $0x33,%edx
call   1040 <write@plt>
lea    0xe1d(%rip),%rdi
mov    $0x1,%esi
call   1050 <printf@plt>
lea    0xb0(%rsp),%r15
mov    %ebp,%edi
mov    %r15,%rsi
mov    $0x800,%edx
call   1070 <read@plt>
mov    %rax,%rbx
lea    0xe0b(%rip),%rdi
mov    %ebx,%esi
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1090 <printresponse@plt>
test   %rbx,%rbx
jne    12e2 <main+0x172>
mov    %ebp,%edi
call   1060 <close@plt>
mov    %r14,%rdi
call   1030 <connect_unix_socket@plt>
mov    %eax,%ebp
lea    0x70(%rsp),%rsi
mov    %ebp,%edi
mov    $0x3c,%edx
call   1040 <write@plt>
lea    0xdb2(%rip),%rdi
mov    $0x2,%esi
call   1050 <printf@plt>
lea    0xb0(%rsp),%r15
mov    %ebp,%edi
mov    %r15,%rsi
mov    $0x800,%edx
call   1070 <read@plt>
mov    %rax,%rbx
lea    0xda0(%rip),%rdi
mov    %ebx,%esi
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1090 <printresponse@plt>
test   %rbx,%rbx
jne    134d <main+0x1dd>
mov    %ebp,%edi
call   1060 <close@plt>
mov    %r14,%rdi
call   1030 <connect_unix_socket@plt>
mov    %eax,%ebp
lea    0x6(%rsp),%rsi
mov    %ebp,%edi
mov    $0x2,%edx
call   1040 <write@plt>
lea    0xd47(%rip),%rdi
mov    $0x3,%esi
call   1050 <printf@plt>
lea    0xb0(%rsp),%r15
mov    %ebp,%edi
mov    %r15,%rsi
mov    $0x800,%edx
call   1070 <read@plt>
mov    %rax,%rbx
lea    0xd35(%rip),%rdi
mov    %ebx,%esi
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1090 <printresponse@plt>
test   %rbx,%rbx
jne    13b8 <main+0x248>
mov    %ebp,%edi
call   1060 <close@plt>
mov    %r14,%rdi
call   1030 <connect_unix_socket@plt>
mov    %eax,%ebp
lea    0x10(%rsp),%rsi
mov    %ebp,%edi
mov    $0x11,%edx
call   1040 <write@plt>
lea    0xcdc(%rip),%rbx
mov    %rbx,%rdi
mov    $0x4,%esi
call   1050 <printf@plt>
lea    0x4(%rsp),%rsi
mov    %ebp,%edi
mov    $0x2,%edx
call   1040 <write@plt>
mov    %rbx,%rdi
mov    $0xffffffff,%esi
call   1050 <printf@plt>
lea    0xb0(%rsp),%r15
mov    %ebp,%edi
mov    %r15,%rsi
mov    $0x800,%edx
call   1070 <read@plt>
mov    %rax,%rbx
lea    0xca9(%rip),%rdi
mov    %ebx,%esi
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1090 <printresponse@plt>
test   %rbx,%rbx
jne    1444 <main+0x2d4>
mov    %ebp,%edi
call   1060 <close@plt>
mov    %r14,%rdi
call   1030 <connect_unix_socket@plt>
mov    %eax,%ebp
lea    0x8(%rsp),%rsi
mov    %ebp,%edi
mov    $0x8,%edx
call   1040 <write@plt>
lea    0xc50(%rip),%rdi
mov    $0x1,%esi
call   1050 <printf@plt>
lea    0xb0(%rsp),%r14
mov    %ebp,%edi
mov    %r14,%rsi
mov    $0x800,%edx
call   1070 <read@plt>
mov    %rax,%rbx
lea    0xc3e(%rip),%rdi
mov    %ebx,%esi
call   1050 <printf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1090 <printresponse@plt>
mov    %ebp,%edi
call   1060 <close@plt>
xor    %eax,%eax
add    $0x8b8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.command1 = [52 x i8] c"\01\00urn:schemas-upnp-org:device:InternetGatewayDevice\00"
@__const.main.command2 = [61 x i8] c"\02\00uuid:fc4ec57e-b051-11db-88f8-0060085db3f6::upnp:rootdevice\00"
@__const.main.command3 = [2 x i8] c"\03\00"
@__const.main.command4 = [17 x i8] c"\04\00test:test:test\00"
@__const.main.bad_command = [2 x i8] c"\FF\FF"
@__const.main.overflow = [8 x i8] c"\01\FF\FF\FF\FF\FF\FF\FF"
@.str = [24 x i8] c"/var/run/minissdpd.sock\00"
@.str.1 = [3 x i8] c"-s\00"
@.str.2 = [25 x i8] c"Command written type=%u\0A\00"
@.str.3 = [28 x i8] c"Response received %d bytes\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [52 x i8]
%7 = alloca [61 x i8]
%8 = alloca [2 x i8]
%9 = alloca [17 x i8]
%10 = alloca [2 x i8]
%11 = alloca [8 x i8]
%12 = alloca i32
%13 = alloca i32
%14 = alloca [2048 x i8]
%15 = alloca i64
%16 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%17 = bitcast [52 x i8]* %6 to i8*
%18 = bitcast [61 x i8]* %7 to i8*
%19 = bitcast [2 x i8]* %8 to i8*
%20 = bitcast [17 x i8]* %9 to i8*
%21 = bitcast [2 x i8]* %10 to i8*
%22 = bitcast [8 x i8]* %11 to i8*
store i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8** %16
store i32 0, i32* %13
br label %23
23: ; preds = %44, %2
%24 = load i32, i32* %13
%25 = load i32, i32* %4
%26 = sub nsw i32 %25, 1
%27 = icmp slt i32 %24, %26
br i1 %27, label %28, label %47
28: ; preds = %23
%29 = load i8**, i8*** %5
%30 = load i32, i32* %13
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8*, i8** %29, i64 %31
%33 = load i8*, i8** %32
%34 = call i64 @strcmp(i8* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%35 = icmp eq i64 0, %34
br i1 %35, label %36, label %43
36: ; preds = %28
%37 = load i8**, i8*** %5
%38 = load i32, i32* %13
%39 = add nsw i32 %38, 1
store i32 %39, i32* %13
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8*, i8** %37, i64 %40
%42 = load i8*, i8** %41
store i8* %42, i8** %16
br label %43
43: ; preds = %36, %28
br label %44
44: ; preds = %43
%45 = load i32, i32* %13
%46 = add nsw i32 %45, 1
store i32 %46, i32* %13
br label %23
47: ; preds = %23
%48 = getelementptr inbounds [52 x i8], [52 x i8]* %6, i64 0, i64 1
store i8 49, i8* %48
%49 = getelementptr inbounds [61 x i8], [61 x i8]* %7, i64 0, i64 1
store i8 58, i8* %49
%50 = getelementptr inbounds [17 x i8], [17 x i8]* %9, i64 0, i64 1
store i8 14, i8* %50
%51 = load i8*, i8** %16
%52 = call i32 @connect_unix_socket(i8* %51)
store i32 %52, i32* %12
%53 = load i32, i32* %12
%54 = getelementptr inbounds [52 x i8], [52 x i8]* %6, i64 0, i64 0
%55 = call i32 @write(i32 %53, i8* %54, i32 51)
%56 = getelementptr inbounds [52 x i8], [52 x i8]* %6, i64 0, i64 0
%57 = load i8, i8* %56
%58 = sext i8 %57 to i32
%59 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %58)
%60 = load i32, i32* %12
%61 = getelementptr inbounds [2048 x i8], [2048 x i8]* %14, i64 0, i64 0
%62 = call i64 @read(i32 %60, i8* %61, i32 2048)
store i64 %62, i64* %15
%63 = load i64, i64* %15
%64 = trunc i64 %63 to i32
%65 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %64)
%66 = getelementptr inbounds [2048 x i8], [2048 x i8]* %14, i64 0, i64 0
%67 = load i64, i64* %15
%68 = call i32 @printresponse(i8* %66, i64 %67)
%69 = load i64, i64* %15
%70 = icmp eq i64 %69, 0
br i1 %70, label %71, label %76
71: ; preds = %47
%72 = load i32, i32* %12
%73 = call i32 @close(i32 %72)
%74 = load i8*, i8** %16
%75 = call i32 @connect_unix_socket(i8* %74)
store i32 %75, i32* %12
br label %76
76: ; preds = %71, %47
%77 = load i32, i32* %12
%78 = getelementptr inbounds [61 x i8], [61 x i8]* %7, i64 0, i64 0
%79 = call i32 @write(i32 %77, i8* %78, i32 60)
%80 = getelementptr inbounds [61 x i8], [61 x i8]* %7, i64 0, i64 0
%81 = load i8, i8* %80
%82 = sext i8 %81 to i32
%83 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %82)
%84 = load i32, i32* %12
%85 = getelementptr inbounds [2048 x i8], [2048 x i8]* %14, i64 0, i64 0
%86 = call i64 @read(i32 %84, i8* %85, i32 2048)
store i64 %86, i64* %15
%87 = load i64, i64* %15
%88 = trunc i64 %87 to i32
%89 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %88)
%90 = getelementptr inbounds [2048 x i8], [2048 x i8]* %14, i64 0, i64 0
%91 = load i64, i64* %15
%92 = call i32 @printresponse(i8* %90, i64 %91)
%93 = load i64, i64* %15
%94 = icmp eq i64 %93, 0
br i1 %94, label %95, label %100
95: ; preds = %76
%96 = load i32, i32* %12
%97 = call i32 @close(i32 %96)
%98 = load i8*, i8** %16
%99 = call i32 @connect_unix_socket(i8* %98)
store i32 %99, i32* %12
br label %100
100: ; preds = %95, %76
%101 = load i32, i32* %12
%102 = getelementptr inbounds [2 x i8], [2 x i8]* %8, i64 0, i64 0
%103 = call i32 @write(i32 %101, i8* %102, i32 2)
%104 = getelementptr inbounds [2 x i8], [2 x i8]* %8, i64 0, i64 0
%105 = load i8, i8* %104
%106 = sext i8 %105 to i32
%107 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %106)
%108 = load i32, i32* %12
%109 = getelementptr inbounds [2048 x i8], [2048 x i8]* %14, i64 0, i64 0
%110 = call i64 @read(i32 %108, i8* %109, i32 2048)
store i64 %110, i64* %15
%111 = load i64, i64* %15
%112 = trunc i64 %111 to i32
%113 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %112)
%114 = getelementptr inbounds [2048 x i8], [2048 x i8]* %14, i64 0, i64 0
%115 = load i64, i64* %15
%116 = call i32 @printresponse(i8* %114, i64 %115)
%117 = load i64, i64* %15
%118 = icmp eq i64 %117, 0
br i1 %118, label %119, label %124
119: ; preds = %100
%120 = load i32, i32* %12
%121 = call i32 @close(i32 %120)
%122 = load i8*, i8** %16
%123 = call i32 @connect_unix_socket(i8* %122)
store i32 %123, i32* %12
br label %124
124: ; preds = %119, %100
%125 = load i32, i32* %12
%126 = getelementptr inbounds [17 x i8], [17 x i8]* %9, i64 0, i64 0
%127 = call i32 @write(i32 %125, i8* %126, i32 17)
%128 = getelementptr inbounds [17 x i8], [17 x i8]* %9, i64 0, i64 0
%129 = load i8, i8* %128
%130 = sext i8 %129 to i32
%131 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %130)
%132 = load i32, i32* %12
%133 = getelementptr inbounds [2 x i8], [2 x i8]* %10, i64 0, i64 0
%134 = call i32 @write(i32 %132, i8* %133, i32 2)
%135 = getelementptr inbounds [2 x i8], [2 x i8]* %10, i64 0, i64 0
%136 = load i8, i8* %135
%137 = sext i8 %136 to i32
%138 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %137)
%139 = load i32, i32* %12
%140 = getelementptr inbounds [2048 x i8], [2048 x i8]* %14, i64 0, i64 0
%141 = call i64 @read(i32 %139, i8* %140, i32 2048)
store i64 %141, i64* %15
%142 = load i64, i64* %15
%143 = trunc i64 %142 to i32
%144 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %143)
%145 = getelementptr inbounds [2048 x i8], [2048 x i8]* %14, i64 0, i64 0
%146 = load i64, i64* %15
%147 = call i32 @printresponse(i8* %145, i64 %146)
%148 = load i64, i64* %15
%149 = icmp eq i64 %148, 0
br i1 %149, label %150, label %155
150: ; preds = %124
%151 = load i32, i32* %12
%152 = call i32 @close(i32 %151)
%153 = load i8*, i8** %16
%154 = call i32 @connect_unix_socket(i8* %153)
store i32 %154, i32* %12
br label %155
155: ; preds = %150, %124
%156 = load i32, i32* %12
%157 = getelementptr inbounds [8 x i8], [8 x i8]* %11, i64 0, i64 0
%158 = call i32 @write(i32 %156, i8* %157, i32 8)
%159 = getelementptr inbounds [8 x i8], [8 x i8]* %11, i64 0, i64 0
%160 = load i8, i8* %159
%161 = sext i8 %160 to i32
%162 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %161)
%163 = load i32, i32* %12
%164 = getelementptr inbounds [2048 x i8], [2048 x i8]* %14, i64 0, i64 0
%165 = call i64 @read(i32 %163, i8* %164, i32 2048)
store i64 %165, i64* %15
%166 = load i64, i64* %15
%167 = trunc i64 %166 to i32
%168 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %167)
%169 = getelementptr inbounds [2048 x i8], [2048 x i8]* %14, i64 0, i64 0
%170 = load i64, i64* %15
%171 = call i32 @printresponse(i8* %169, i64 %170)
%172 = load i32, i32* %12
%173 = call i32 @close(i32 %172)
ret i32 0
}

LLVM IR (-O2):
@__const.main.command1 = [52 x i8] c"\01\00urn:schemas-upnp-org:device:InternetGatewayDevice\00"
@__const.main.command2 = [61 x i8] c"\02\00uuid:fc4ec57e-b051-11db-88f8-0060085db3f6::upnp:rootdevice\00"
@__const.main.command4 = [17 x i8] c"\04\00test:test:test\00"
@.str = [24 x i8] c"/var/run/minissdpd.sock\00"
@.str.1 = [3 x i8] c"-s\00"
@.str.2 = [25 x i8] c"Command written type=%u\0A\00"
@.str.3 = [28 x i8] c"Response received %d bytes\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [52 x i8]
%4 = alloca [61 x i8]
%5 = alloca i16
%6 = alloca [17 x i8]
%7 = alloca i16
%8 = alloca i64
%9 = alloca [2048 x i8]
%10 = getelementptr inbounds [52 x i8], [52 x i8]* %3, i64 0, i64 0
%11 = getelementptr inbounds [61 x i8], [61 x i8]* %4, i64 0, i64 0
%12 = bitcast i16* %5 to i8*
store i16 3, i16* %5
%13 = getelementptr inbounds [17 x i8], [17 x i8]* %6, i64 0, i64 0
%14 = bitcast i16* %7 to i8*
store i16 -1, i16* %7
%15 = bitcast i64* %8 to i8*
store i64 -255, i64* %8
%16 = getelementptr inbounds [2048 x i8], [2048 x i8]* %9, i64 0, i64 0
%17 = add nsw i32 %0, -1
%18 = icmp sgt i32 %0, 1
br i1 %18, label %19, label %37
19: ; preds = %2, %32
%20 = phi i8* [ %34, %32 ], [ getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), %2 ]
%21 = phi i32 [ %35, %32 ], [ 0, %2 ]
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8*, i8** %1, i64 %22
%24 = load i8*, i8** %23
%25 = tail call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %32
27: ; preds = %19
%28 = add nsw i32 %21, 1
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8*, i8** %1, i64 %29
%31 = load i8*, i8** %30
br label %32
32: ; preds = %19, %27
%33 = phi i32 [ %28, %27 ], [ %21, %19 ]
%34 = phi i8* [ %31, %27 ], [ %20, %19 ]
%35 = add nsw i32 %33, 1
%36 = icmp slt i32 %35, %17
br i1 %36, label %19, label %37
37: ; preds = %32, %2
%38 = phi i8* [ getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), %2 ], [ %34, %32 ]
%39 = getelementptr inbounds [52 x i8], [52 x i8]* %3, i64 0, i64 1
store i8 49, i8* %39
%40 = getelementptr inbounds [61 x i8], [61 x i8]* %4, i64 0, i64 1
store i8 58, i8* %40
%41 = getelementptr inbounds [17 x i8], [17 x i8]* %6, i64 0, i64 1
store i8 14, i8* %41
%42 = tail call i32 @connect_unix_socket(i8* %38)
%43 = call i32 @write(i32 %42, i8* %10, i32 51)
%44 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 1)
%45 = call i64 @read(i32 %42, i8* %16, i32 2048)
%46 = trunc i64 %45 to i32
%47 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %46)
%48 = call i32 @printresponse(i8* %16, i64 %45)
%49 = icmp eq i64 %45, 0
br i1 %49, label %50, label %53
50: ; preds = %37
%51 = call i32 @close(i32 %42)
%52 = call i32 @connect_unix_socket(i8* %38)
br label %53
53: ; preds = %50, %37
%54 = phi i32 [ %52, %50 ], [ %42, %37 ]
%55 = call i32 @write(i32 %54, i8* %11, i32 60)
%56 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 2)
%57 = call i64 @read(i32 %54, i8* %16, i32 2048)
%58 = trunc i64 %57 to i32
%59 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %58)
%60 = call i32 @printresponse(i8* %16, i64 %57)
%61 = icmp eq i64 %57, 0
br i1 %61, label %62, label %65
62: ; preds = %53
%63 = call i32 @close(i32 %54)
%64 = call i32 @connect_unix_socket(i8* %38)
br label %65
65: ; preds = %62, %53
%66 = phi i32 [ %64, %62 ], [ %54, %53 ]
%67 = call i32 @write(i32 %66, i8* %12, i32 2)
%68 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 3)
%69 = call i64 @read(i32 %66, i8* %16, i32 2048)
%70 = trunc i64 %69 to i32
%71 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %70)
%72 = call i32 @printresponse(i8* %16, i64 %69)
%73 = icmp eq i64 %69, 0
br i1 %73, label %74, label %77
74: ; preds = %65
%75 = call i32 @close(i32 %66)
%76 = call i32 @connect_unix_socket(i8* %38)
br label %77
77: ; preds = %74, %65
%78 = phi i32 [ %76, %74 ], [ %66, %65 ]
%79 = call i32 @write(i32 %78, i8* %13, i32 17)
%80 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 4)
%81 = call i32 @write(i32 %78, i8* %14, i32 2)
%82 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 -1)
%83 = call i64 @read(i32 %78, i8* %16, i32 2048)
%84 = trunc i64 %83 to i32
%85 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %84)
%86 = call i32 @printresponse(i8* %16, i64 %83)
%87 = icmp eq i64 %83, 0
br i1 %87, label %88, label %91
88: ; preds = %77
%89 = call i32 @close(i32 %78)
%90 = call i32 @connect_unix_socket(i8* %38)
br label %91
91: ; preds = %88, %77
%92 = phi i32 [ %90, %88 ], [ %78, %77 ]
%93 = call i32 @write(i32 %92, i8* %15, i32 8)
%94 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 1)
%95 = call i64 @read(i32 %92, i8* %16, i32 2048)
%96 = trunc i64 %95 to i32
%97 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %96)
%98 = call i32 @printresponse(i8* %16, i64 %95)
%99 = call i32 @close(i32 %92)
ret i32 0
}