#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*/ SHUT_RDWR;
int /*<<< orphan*/ bzero(char *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ read(int, char *, int);
int /*<<< orphan*/ shutdown(int, int /*<<< orphan*/);
int socket_connect(char *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ write(int, char *, int /*<<< orphan*/);
int log_dummy_message() {
  int fd;
  char buffer[1024];
  fd = socket_connect("localhost", 8900);
  write(fd, "POST /log/dummy HTTP/1.0\r\n\r\n",
        strlen("POST /log/dummy HTTP/1.0\r\n\r\n"));
  bzero(buffer, 1024);
  while (read(fd, buffer, 1024 - 1) != 0) {
    fprintf(stderr, "%s", buffer);
    bzero(buffer, 1024);
  }
  shutdown(fd, SHUT_RDWR);
  close(fd);
  return 0;
}


x86 assembly (clang, -O0):
<log_dummy_message>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
lea    0xe6e(%rip),%rdi
mov    $0x22c4,%esi
call   1090 <socket_connect@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x414(%rbp)
lea    0xe5b(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x414(%rbp),%edi
mov    %eax,%edx
lea    0xe47(%rip),%rsi
call   1030 <write@plt>
lea    -0x410(%rbp),%rdi
mov    $0x400,%esi
call   10a0 <bzero@plt>
mov    -0x4(%rbp),%edi
lea    -0x410(%rbp),%rsi
mov    $0x3ff,%edx
call   1070 <read@plt>
cmp    $0x0,%rax
je     1229 <log_dummy_message+0xa9>
mov    0x2dda(%rip),%rax
mov    (%rax),%edi
lea    -0x410(%rbp),%rdx
lea    0xe19(%rip),%rsi
call   1080 <fprintf@plt>
lea    -0x410(%rbp),%rdi
mov    $0x400,%esi
call   10a0 <bzero@plt>
jmp    11d9 <log_dummy_message+0x59>
mov    -0x4(%rbp),%edi
mov    0x2dbd(%rip),%rax
mov    (%rax),%esi
call   1040 <shutdown@plt>
mov    -0x4(%rbp),%edi
call   1060 <close@plt>
xor    %eax,%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<log_dummy_message>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x408,%rsp
lea    0xe6c(%rip),%rdi
mov    $0x22c4,%esi
call   1090 <socket_connect@plt>
mov    %eax,%ebp
lea    0xe63(%rip),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x400,%esi
call   10a0 <bzero@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x3ff,%edx
call   1070 <read@plt>
test   %rax,%rax
je     121f <log_dummy_message+0x9f>
mov    0x2df2(%rip),%r15
lea    0xe3a(%rip),%r14
mov    %rsp,%rbx
mov    (%r15),%edi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1080 <fprintf@plt>
mov    %rbx,%rdi
mov    $0x400,%esi
call   10a0 <bzero@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x3ff,%edx
call   1070 <read@plt>
test   %rax,%rax
jne    11f0 <log_dummy_message+0x70>
mov    0x2dca(%rip),%rax
mov    (%rax),%esi
mov    %ebp,%edi
call   1040 <shutdown@plt>
mov    %ebp,%edi
call   1060 <close@plt>
xor    %eax,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"localhost\00"
@.str.1 = [29 x i8] c"POST /log/dummy HTTP/1.0\0D\0A\0D\0A\00"
@stderr = global i32 0
@.str.2 = [3 x i8] c"%s\00"
@SHUT_RDWR = global i32 0
define i32 @log_dummy_message() {
%1 = alloca i32
%2 = alloca [1024 x i8]
%3 = call i32 @socket_connect(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 8900)
store i32 %3, i32* %1
%4 = load i32, i32* %1
%5 = call i32 @strlen(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @write(i32 %4, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%8 = call i32 @bzero(i8* %7, i32 1024)
br label %9
9: ; preds = %14, %0
%10 = load i32, i32* %1
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%12 = call i64 @read(i32 %10, i8* %11, i32 1023)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %20
14: ; preds = %9
%15 = load i32, i32* @stderr
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%17 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %16)
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%19 = call i32 @bzero(i8* %18, i32 1024)
br label %9
20: ; preds = %9
%21 = load i32, i32* %1
%22 = load i32, i32* @SHUT_RDWR
%23 = call i32 @shutdown(i32 %21, i32 %22)
%24 = load i32, i32* %1
%25 = call i32 @close(i32 %24)
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"localhost\00"
@.str.1 = [29 x i8] c"POST /log/dummy HTTP/1.0\0D\0A\0D\0A\00"
@stderr = global i32 0
@.str.2 = [3 x i8] c"%s\00"
@SHUT_RDWR = global i32 0
define i32 @log_dummy_message() {
%1 = alloca [1024 x i8]
%2 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @socket_connect(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 8900)
%4 = tail call i32 @strlen(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 @write(i32 %3, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 %4)
%6 = call i32 @bzero(i8* %2, i32 1024)
%7 = call i64 @read(i32 %3, i8* %2, i32 1023)
%8 = icmp eq i64 %7, 0
br i1 %8, label %15, label %9
9: ; preds = %0, %9
%10 = load i32, i32* @stderr
%11 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%12 = call i32 @bzero(i8* %2, i32 1024)
%13 = call i64 @read(i32 %3, i8* %2, i32 1023)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %9
15: ; preds = %9, %0
%16 = load i32, i32* @SHUT_RDWR
%17 = call i32 @shutdown(i32 %3, i32 %16)
%18 = call i32 @close(i32 %3)
ret i32 0
}