#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 sockaddr_in {
  int /*<<< orphan*/ sin_addr;
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ str;
typedef int /*<<< orphan*/ inet;
typedef int /*<<< orphan*/ arguments;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int EXIT_FAILURE;
int /*<<< orphan*/ LOG_DAEMON;
int /*<<< orphan*/ LOG_ERR;
int /*<<< orphan*/ LOG_INFO;
int /*<<< orphan*/ LOG_PID;
int /*<<< orphan*/ PF_INET;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ atoi(char const *);
int /*<<< orphan*/ close(int);
int connect(int, struct sockaddr *, int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
scalar_t__ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ htons(int /*<<< orphan*/);
int inet_pton(int /*<<< orphan*/, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(char *, char, int);
int /*<<< orphan*/ openlog(char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int recv(int, char *, int, int /*<<< orphan*/);
int send(int, char *, int, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int strlen(char *);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, ...);
int main(int argc, char const *argv[]) {
  int a, i, j, n, s, t, len;
  struct sockaddr_in inet;
  char arguments[100], str[10000];
  memset(str, '\0', strlen(str));
  openlog("Thomas", LOG_PID, LOG_DAEMON);
  syslog(LOG_INFO, "starting");
  if ((s = socket(PF_INET, SOCK_STREAM, 0)) == -1) {
    syslog(LOG_ERR, "%s", strerror(errno));
    exit(1);
  }
  printf("Trying to connect...\n");
  inet.sin_family = AF_INET;
  inet.sin_port = htons(atoi(argv[1]));
  if ((inet_pton(AF_INET, "192.168.56.101", &inet.sin_addr)) == -1) {
    syslog(LOG_ERR, "%s", strerror(errno));
    exit(EXIT_FAILURE);
  }
  if (connect(s, (struct sockaddr *)&inet, sizeof(inet)) == -1) {
    syslog(LOG_ERR, "%s", strerror(errno));
    exit(1);
  }
  printf("Connected.\n");
  memset(arguments, '\0', sizeof(arguments));
  while (printf("Ange kommando > ") &&
         fgets(arguments, sizeof(arguments), stdin)) {
    arguments[strlen(arguments) - 1] = '\0';
    printf("Du skrev: %s\n", arguments);
    if (send(s, arguments, sizeof(arguments), 0) == -1) {
      perror("send");
      exit(1);
    }
    while ((t = recv(s, str, 100, 0)) > 0) {
      str[t] = '\0';
      printf("retur: %s\n", (str));
      if (!(strcmp(str, "")))
        break;
    }
    if (t < 0) {
      perror("recv");
      exit(1);
    } else if (t == 0)
      printf("Server closed connection\n");
    else {
      printf("%s\n", str);
      memset(str, '\0', sizeof(str));
    }
  }
  close(s);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x27d0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x27b0(%rbp),%rax
mov    %rax,-0x27b8(%rbp)
lea    -0x27b0(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x27b8(%rbp),%rdi
mov    %eax,%edx
xor    %esi,%esi
call   1080 <memset@plt>
mov    0x2d5e(%rip),%rax
mov    (%rax),%esi
mov    0x2d75(%rip),%rax
mov    (%rax),%edx
lea    0xd84(%rip),%rdi
call   1100 <openlog@plt>
mov    0x2d18(%rip),%rax
mov    (%rax),%edi
lea    0xd76(%rip),%rsi
mov    $0x0,%al
call   10d0 <syslog@plt>
mov    0x2d11(%rip),%rax
mov    (%rax),%edi
mov    0x2d18(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1140 <socket@plt>
mov    %eax,-0x24(%rbp)
cmp    $0xffffffff,%eax
jne    12fa <main+0xda>
mov    0x2ccc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x27bc(%rbp)
mov    0x2ce5(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
mov    -0x27bc(%rbp),%edi
mov    %eax,%edx
lea    0xd27(%rip),%rsi
mov    $0x0,%al
call   10d0 <syslog@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
lea    0xd12(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    0x2cd1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10f0 <atoi@plt>
mov    %eax,%edi
call   1050 <htons@plt>
mov    %eax,-0x34(%rbp)
mov    0x2cae(%rip),%rax
mov    (%rax),%edi
lea    -0x38(%rbp),%rdx
lea    0xcea(%rip),%rsi
call   10c0 <inet_pton@plt>
cmp    $0xffffffff,%eax
jne    138e <main+0x16e>
mov    0x2c3c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x27c0(%rbp)
mov    0x2c55(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
mov    -0x27c0(%rbp),%edi
mov    %eax,%edx
lea    0xc97(%rip),%rsi
mov    $0x0,%al
call   10d0 <syslog@plt>
mov    0x2c21(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
mov    -0x24(%rbp),%edi
lea    -0x38(%rbp),%rsi
mov    $0xc,%edx
call   1120 <connect@plt>
cmp    $0xffffffff,%eax
jne    13e5 <main+0x1c5>
mov    0x2be1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x27c4(%rbp)
mov    0x2bfa(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
mov    -0x27c4(%rbp),%edi
mov    %eax,%edx
lea    0xc3c(%rip),%rsi
mov    $0x0,%al
call   10d0 <syslog@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
lea    0xc4c(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0xa0(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1080 <memset@plt>
lea    0xc37(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x27c5(%rbp)
je     144e <main+0x22e>
lea    -0xa0(%rbp),%rdi
mov    0x2ba3(%rip),%rax
mov    (%rax),%edx
mov    $0x64,%esi
call   10a0 <fgets@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x27c5(%rbp)
mov    -0x27c5(%rbp),%al
test   $0x1,%al
jne    1461 <main+0x241>
jmp    15a1 <main+0x381>
lea    -0xa0(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0xa0(%rbp,%rax,1)
lea    -0xa0(%rbp),%rsi
lea    0xbcd(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x24(%rbp),%edi
lea    -0xa0(%rbp),%rsi
mov    $0x64,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
cmp    $0xffffffff,%eax
jne    14c4 <main+0x2a4>
lea    0xbae(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
jmp    14c9 <main+0x2a9>
mov    -0x24(%rbp),%edi
lea    -0x27b0(%rbp),%rsi
mov    $0x64,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,-0x28(%rbp)
cmp    $0x0,%eax
jle    1532 <main+0x312>
movslq -0x28(%rbp),%rax
movb   $0x0,-0x27b0(%rbp,%rax,1)
lea    -0x27b0(%rbp),%rsi
lea    0xb63(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x27b0(%rbp),%rdi
lea    0xb0e(%rip),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%eax
jne    152d <main+0x30d>
jmp    1532 <main+0x312>
jmp    14c9 <main+0x2a9>
cmpl   $0x0,-0x28(%rbp)
jge    1552 <main+0x332>
lea    0xb30(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
cmpl   $0x0,-0x28(%rbp)
jne    156f <main+0x34f>
lea    0xb15(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1597 <main+0x377>
lea    -0x27b0(%rbp),%rsi
lea    0xaf2(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x27b0(%rbp),%rdi
xor    %esi,%esi
mov    $0x2710,%edx
call   1080 <memset@plt>
jmp    159c <main+0x37c>
jmp    1406 <main+0x1e6>
mov    -0x24(%rbp),%edi
call   1090 <close@plt>
xor    %eax,%eax
add    $0x27d0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2798,%rsp
mov    %rsi,%r14
lea    0x80(%rsp),%rbp
mov    %rbp,%rdi
call   1050 <strlen@plt>
mov    %rbp,%rdi
xor    %esi,%esi
mov    %eax,%edx
call   1090 <memset@plt>
mov    0x2d71(%rip),%rax
mov    (%rax),%esi
mov    0x2d88(%rip),%rax
mov    (%rax),%edx
lea    0xd97(%rip),%rdi
call   1100 <openlog@plt>
mov    0x2d2b(%rip),%rax
mov    (%rax),%edi
lea    0xd89(%rip),%rsi
xor    %eax,%eax
call   10d0 <syslog@plt>
mov    0x2d24(%rip),%rax
mov    (%rax),%edi
mov    0x2d2b(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1140 <socket@plt>
cmp    $0xffffffff,%eax
je     147d <main+0x25d>
mov    %eax,%ebp
lea    0xda6(%rip),%rdi
call   1040 <puts@plt>
mov    0x2d24(%rip),%rbx
mov    (%rbx),%eax
mov    %eax,0x8(%rsp)
mov    0x8(%r14),%rdi
call   10f0 <atoi@plt>
mov    %eax,%edi
call   1060 <htons@plt>
mov    %eax,0x4(%rsp)
mov    (%rbx),%edi
lea    0xd34(%rip),%rsi
mov    %rsp,%rdx
call   10c0 <inet_pton@plt>
cmp    $0xffffffff,%eax
je     14b0 <main+0x290>
mov    %rsp,%rsi
mov    %ebp,%edi
mov    $0xc,%edx
call   1120 <connect@plt>
cmp    $0xffffffff,%eax
je     147d <main+0x25d>
lea    0xd5c(%rip),%rdi
call   1040 <puts@plt>
lea    0x10(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1090 <memset@plt>
lea    0xcf3(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
test   %eax,%eax
je     1443 <main+0x223>
mov    0x2c93(%rip),%r15
lea    0x80(%rsp),%rbx
lea    0xcf2(%rip),%r12
lea    0xcc7(%rip),%r13
jmp    1372 <main+0x152>
nopl   (%rax)
mov    %r13,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
test   %eax,%eax
je     1443 <main+0x223>
mov    (%r15),%edx
mov    %r14,%rdi
mov    $0x64,%esi
call   10b0 <fgets@plt>
test   %rax,%rax
je     1443 <main+0x223>
mov    %r14,%rdi
call   1050 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%r14,1)
lea    0xc91(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %ebp,%edi
mov    %r14,%rsi
mov    $0x64,%edx
xor    %ecx,%ecx
call   1070 <send@plt>
cmp    $0xffffffff,%eax
je     145e <main+0x23e>
cs nopw 0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x64,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
test   %eax,%eax
jle    1430 <main+0x210>
mov    %eax,%eax
movb   $0x0,0x80(%rsp,%rax,1)
mov    %r12,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
cmpb   $0x0,0x80(%rsp)
jne    13d0 <main+0x1b0>
mov    %rbx,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x2710,%edx
call   1090 <memset@plt>
jmp    1360 <main+0x140>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
js     1467 <main+0x247>
lea    0xc3d(%rip),%rdi
call   1040 <puts@plt>
jmp    1360 <main+0x140>
mov    %ebp,%edi
call   10a0 <close@plt>
xor    %eax,%eax
add    $0x2798,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xbdc(%rip),%rdi
jmp    146e <main+0x24e>
lea    0xbe3(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    0x2b0c(%rip),%rax
mov    (%rax),%ebx
mov    0x2b2b(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
lea    0xb75(%rip),%rsi
mov    %ebx,%edi
mov    %eax,%edx
xor    %eax,%eax
call   10d0 <syslog@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    0x2ad9(%rip),%rax
mov    (%rax),%ebx
mov    0x2af8(%rip),%rax
mov    (%rax),%edi
call   1130 <strerror@plt>
lea    0xb42(%rip),%rsi
mov    %ebx,%edi
mov    %eax,%edx
xor    %eax,%eax
call   10d0 <syslog@plt>
mov    0x2ac8(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, i32, i32 }
%struct.sockaddr = type { i32 }
@.str = [7 x i8] c"Thomas\00"
@LOG_PID = global i32 0
@LOG_DAEMON = global i32 0
@LOG_INFO = global i32 0
@.str.1 = [9 x i8] c"starting\00"
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@LOG_ERR = global i32 0
@.str.2 = [3 x i8] c"%s\00"
@errno = global i32 0
@.str.3 = [22 x i8] c"Trying to connect...\0A\00"
@AF_INET = global i32 0
@.str.4 = [15 x i8] c"192.168.56.101\00"
@EXIT_FAILURE = global i32 0
@.str.5 = [12 x i8] c"Connected.\0A\00"
@.str.6 = [17 x i8] c"Ange kommando > \00"
@stdin = global i32 0
@.str.7 = [14 x i8] c"Du skrev: %s\0A\00"
@.str.8 = [5 x i8] c"send\00"
@.str.9 = [11 x i8] c"retur: %s\0A\00"
@.str.10 = [1 x i8] zeroinitializer
@.str.11 = [5 x i8] c"recv\00"
@.str.12 = [26 x i8] c"Server closed connection\0A\00"
@.str.13 = [4 x i8] c"%s\0A\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 i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca %struct.sockaddr_in
%14 = alloca [100 x i8]
%15 = alloca [10000 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%16 = getelementptr inbounds [10000 x i8], [10000 x i8]* %15, i64 0, i64 0
%17 = getelementptr inbounds [10000 x i8], [10000 x i8]* %15, i64 0, i64 0
%18 = call i32 @strlen(i8* %17)
%19 = call i32 @memset(i8* %16, i8 signext 0, i32 %18)
%20 = load i32, i32* @LOG_PID
%21 = load i32, i32* @LOG_DAEMON
%22 = call i32 @openlog(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %20, i32 %21)
%23 = load i32, i32* @LOG_INFO
%24 = call i32 (i32, i8*, ...) @syslog(i32 %23, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%25 = load i32, i32* @PF_INET
%26 = load i32, i32* @SOCK_STREAM
%27 = call i32 @socket(i32 %25, i32 %26, i32 0)
store i32 %27, i32* %10
%28 = icmp eq i32 %27, -1
br i1 %28, label %29, label %35
29: ; preds = %2
%30 = load i32, i32* @LOG_ERR
%31 = load i32, i32* @errno
%32 = call i32 @strerror(i32 %31)
%33 = call i32 (i32, i8*, ...) @syslog(i32 %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %32)
%34 = call i32 @exit(i32 1)
unreachable
35: ; preds = %2
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%37 = load i32, i32* @AF_INET
%38 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %13, i32 0, i32 2
store i32 %37, i32* %38
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 1
%41 = load i8*, i8** %40
%42 = call i32 @atoi(i8* %41)
%43 = call i32 @htons(i32 %42)
%44 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %13, i32 0, i32 1
store i32 %43, i32* %44
%45 = load i32, i32* @AF_INET
%46 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %13, i32 0, i32 0
%47 = call i32 @inet_pton(i32 %45, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32* %46)
%48 = icmp eq i32 %47, -1
br i1 %48, label %49, label %56
49: ; preds = %35
%50 = load i32, i32* @LOG_ERR
%51 = load i32, i32* @errno
%52 = call i32 @strerror(i32 %51)
%53 = call i32 (i32, i8*, ...) @syslog(i32 %50, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %52)
%54 = load i32, i32* @EXIT_FAILURE
%55 = call i32 @exit(i32 %54)
unreachable
56: ; preds = %35
%57 = load i32, i32* %10
%58 = bitcast %struct.sockaddr_in* %13 to %struct.sockaddr*
%59 = call i32 @connect(i32 %57, %struct.sockaddr* %58, i32 12)
%60 = icmp eq i32 %59, -1
br i1 %60, label %61, label %67
61: ; preds = %56
%62 = load i32, i32* @LOG_ERR
%63 = load i32, i32* @errno
%64 = call i32 @strerror(i32 %63)
%65 = call i32 (i32, i8*, ...) @syslog(i32 %62, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %64)
%66 = call i32 @exit(i32 1)
unreachable
67: ; preds = %56
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
%69 = getelementptr inbounds [100 x i8], [100 x i8]* %14, i64 0, i64 0
%70 = call i32 @memset(i8* %69, i8 signext 0, i32 100)
br label %71
71: ; preds = %130, %67
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
%73 = icmp ne i32 %72, 0
br i1 %73, label %74, label %79
74: ; preds = %71
%75 = getelementptr inbounds [100 x i8], [100 x i8]* %14, i64 0, i64 0
%76 = load i32, i32* @stdin
%77 = call i64 @fgets(i8* %75, i32 100, i32 %76)
%78 = icmp ne i64 %77, 0
br label %79
79: ; preds = %74, %71
%80 = phi i1 [ false, %71 ], [ %78, %74 ]
br i1 %80, label %81, label %131
81: ; preds = %79
%82 = getelementptr inbounds [100 x i8], [100 x i8]* %14, i64 0, i64 0
%83 = call i32 @strlen(i8* %82)
%84 = sub nsw i32 %83, 1
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds [100 x i8], [100 x i8]* %14, i64 0, i64 %85
store i8 0, i8* %86
%87 = getelementptr inbounds [100 x i8], [100 x i8]* %14, i64 0, i64 0
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i8* %87)
%89 = load i32, i32* %10
%90 = getelementptr inbounds [100 x i8], [100 x i8]* %14, i64 0, i64 0
%91 = call i32 @send(i32 %89, i8* %90, i32 100, i32 0)
%92 = icmp eq i32 %91, -1
br i1 %92, label %93, label %96
93: ; preds = %81
%94 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%95 = call i32 @exit(i32 1)
unreachable
96: ; preds = %81
br label %97
97: ; preds = %112, %96
%98 = load i32, i32* %10
%99 = getelementptr inbounds [10000 x i8], [10000 x i8]* %15, i64 0, i64 0
%100 = call i32 @recv(i32 %98, i8* %99, i32 100, i32 0)
store i32 %100, i32* %11
%101 = icmp sgt i32 %100, 0
br i1 %101, label %102, label %113
102: ; preds = %97
%103 = load i32, i32* %11
%104 = sext i32 %103 to i64
%105 = getelementptr inbounds [10000 x i8], [10000 x i8]* %15, i64 0, i64 %104
store i8 0, i8* %105
%106 = getelementptr inbounds [10000 x i8], [10000 x i8]* %15, i64 0, i64 0
%107 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i8* %106)
%108 = getelementptr inbounds [10000 x i8], [10000 x i8]* %15, i64 0, i64 0
%109 = call i32 @strcmp(i8* %108, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.10, i64 0, i64 0))
%110 = icmp ne i32 %109, 0
br i1 %110, label %112, label %111
111: ; preds = %102
br label %113
112: ; preds = %102
br label %97
113: ; preds = %111, %97
%114 = load i32, i32* %11
%115 = icmp slt i32 %114, 0
br i1 %115, label %116, label %119
116: ; preds = %113
%117 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
%118 = call i32 @exit(i32 1)
unreachable
119: ; preds = %113
%120 = load i32, i32* %11
%121 = icmp eq i32 %120, 0
br i1 %121, label %122, label %124
122: ; preds = %119
%123 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.12, i64 0, i64 0))
br label %129
124: ; preds = %119
%125 = getelementptr inbounds [10000 x i8], [10000 x i8]* %15, i64 0, i64 0
%126 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i64 0, i64 0), i8* %125)
%127 = getelementptr inbounds [10000 x i8], [10000 x i8]* %15, i64 0, i64 0
%128 = call i32 @memset(i8* %127, i8 signext 0, i32 10000)
br label %129
129: ; preds = %124, %122
br label %130
130: ; preds = %129
br label %71
131: ; preds = %79
%132 = load i32, i32* %10
%133 = call i32 @close(i32 %132)
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i32, i32 }
%struct.sockaddr = type { i32 }
@.str = [7 x i8] c"Thomas\00"
@LOG_PID = global i32 0
@LOG_DAEMON = global i32 0
@LOG_INFO = global i32 0
@.str.1 = [9 x i8] c"starting\00"
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@LOG_ERR = global i32 0
@.str.2 = [3 x i8] c"%s\00"
@errno = global i32 0
@AF_INET = global i32 0
@.str.4 = [15 x i8] c"192.168.56.101\00"
@EXIT_FAILURE = global i32 0
@.str.6 = [17 x i8] c"Ange kommando > \00"
@stdin = global i32 0
@.str.7 = [14 x i8] c"Du skrev: %s\0A\00"
@.str.8 = [5 x i8] c"send\00"
@.str.9 = [11 x i8] c"retur: %s\0A\00"
@.str.11 = [5 x i8] c"recv\00"
@str = [21 x i8] c"Trying to connect...\00"
@str.14 = [11 x i8] c"Connected.\00"
@str.15 = [25 x i8] c"Server closed connection\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca [100 x i8]
%5 = alloca [10000 x i8]
%6 = bitcast %struct.sockaddr_in* %3 to i8*
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [10000 x i8], [10000 x i8]* %5, i64 0, i64 0
%9 = call i32 @strlen(i8* %8)
%10 = call i32 @memset(i8* %8, i8 signext 0, i32 %9)
%11 = load i32, i32* @LOG_PID
%12 = load i32, i32* @LOG_DAEMON
%13 = call i32 @openlog(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %11, i32 %12)
%14 = load i32, i32* @LOG_INFO
%15 = call i32 (i32, i8*, ...) @syslog(i32 %14, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%16 = load i32, i32* @PF_INET
%17 = load i32, i32* @SOCK_STREAM
%18 = call i32 @socket(i32 %16, i32 %17, i32 0)
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %26
20: ; preds = %2
%21 = load i32, i32* @LOG_ERR
%22 = load i32, i32* @errno
%23 = call i32 @strerror(i32 %22)
%24 = call i32 (i32, i8*, ...) @syslog(i32 %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %23)
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %2
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%28 = load i32, i32* @AF_INET
%29 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %28, i32* %29
%30 = getelementptr inbounds i8*, i8** %1, i64 1
%31 = load i8*, i8** %30
%32 = call i32 @atoi(i8* %31)
%33 = call i32 @htons(i32 %32)
%34 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1
store i32 %33, i32* %34
%35 = load i32, i32* @AF_INET
%36 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
%37 = call i32 @inet_pton(i32 %35, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32* %36)
%38 = icmp eq i32 %37, -1
br i1 %38, label %39, label %46
39: ; preds = %26
%40 = load i32, i32* @LOG_ERR
%41 = load i32, i32* @errno
%42 = call i32 @strerror(i32 %41)
%43 = call i32 (i32, i8*, ...) @syslog(i32 %40, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %42)
%44 = load i32, i32* @EXIT_FAILURE
%45 = call i32 @exit(i32 %44)
unreachable
46: ; preds = %26
%47 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%48 = call i32 @connect(i32 %18, %struct.sockaddr* %47, i32 12)
%49 = icmp eq i32 %48, -1
br i1 %49, label %50, label %56
50: ; preds = %46
%51 = load i32, i32* @LOG_ERR
%52 = load i32, i32* @errno
%53 = call i32 @strerror(i32 %52)
%54 = call i32 (i32, i8*, ...) @syslog(i32 %51, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %53)
%55 = call i32 @exit(i32 1)
unreachable
56: ; preds = %46
%57 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.14, i64 0, i64 0))
%58 = call i32 @memset(i8* %7, i8 signext 0, i32 100)
%59 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
%60 = icmp eq i32 %59, 0
br i1 %60, label %98, label %61
61: ; preds = %56, %95
%62 = load i32, i32* @stdin
%63 = call i64 @fgets(i8* %7, i32 100, i32 %62)
%64 = icmp eq i64 %63, 0
br i1 %64, label %98, label %65
65: ; preds = %61
%66 = call i32 @strlen(i8* %7)
%67 = add nsw i32 %66, -1
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 %68
store i8 0, i8* %69
%70 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i8* %7)
%71 = call i32 @send(i32 %18, i8* %7, i32 100, i32 0)
%72 = icmp eq i32 %71, -1
br i1 %72, label %73, label %76
73: ; preds = %65
%74 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%75 = call i32 @exit(i32 1)
unreachable
76: ; preds = %65, %79
%77 = call i32 @recv(i32 %18, i8* %8, i32 100, i32 0)
%78 = icmp sgt i32 %77, 0
br i1 %78, label %79, label %85
79: ; preds = %76
%80 = zext i32 %77 to i64
%81 = getelementptr inbounds [10000 x i8], [10000 x i8]* %5, i64 0, i64 %80
store i8 0, i8* %81
%82 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i8* %8)
%83 = load i8, i8* %8
%84 = icmp eq i8 %83, 0
br i1 %84, label %92, label %76
85: ; preds = %76
%86 = icmp slt i32 %77, 0
br i1 %86, label %87, label %90
87: ; preds = %85
%88 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
%89 = call i32 @exit(i32 1)
unreachable
90: ; preds = %85
%91 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.15, i64 0, i64 0))
br label %95
92: ; preds = %79
%93 = call i32 @puts(i8* %8)
%94 = call i32 @memset(i8* %8, i8 signext 0, i32 10000)
br label %95
95: ; preds = %90, %92
%96 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
%97 = icmp eq i32 %96, 0
br i1 %97, label %98, label %61
98: ; preds = %61, %95, %56
%99 = call i32 @close(i32 %18)
ret i32 0
}