#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 int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fileno(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ strlen(char const *);
int /*<<< orphan*/ write(int /*<<< orphan*/, char const *, int /*<<< orphan*/);
void log_request(const char *time, const char *req, const char *version,
                 const char *host, const char *uri, const char *ip,
                 const char *action, const char *errors) {
  FILE *logfile = fopen("proxy.log", "a");
  if (time != NULL) {
    write(fileno(logfile), time, strlen(time));
  }
  if (req != NULL) {
    write(fileno(logfile), req, strlen(req));
  }
  if (version != NULL) {
    write(fileno(logfile), version, strlen(version));
  }
  if (host != NULL) {
    write(fileno(logfile), host, strlen(host));
  }
  if (uri != NULL) {
    write(fileno(logfile), uri, strlen(uri));
  }
  if (ip != NULL) {
    write(fileno(logfile), ip, strlen(ip));
  }
  if (action != NULL) {
    write(fileno(logfile), action, strlen(action));
  }
  if (errors != NULL) {
    write(fileno(logfile), errors, strlen(errors));
  }
  fclose(logfile);
}


x86 assembly (clang, -O0):
<log_request>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
lea    0xe7e(%rip),%rdi
lea    0xe81(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11c8 <log_request+0x78>
mov    -0x38(%rbp),%rdi
call   1060 <fileno@plt>
mov    %eax,-0x44(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x44(%rbp),%edi
mov    -0x40(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
cmpq   $0x0,-0x10(%rbp)
je     11fe <log_request+0xae>
mov    -0x38(%rbp),%rdi
call   1060 <fileno@plt>
mov    %eax,-0x54(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x54(%rbp),%edi
mov    -0x50(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
cmpq   $0x0,-0x18(%rbp)
je     1234 <log_request+0xe4>
mov    -0x38(%rbp),%rdi
call   1060 <fileno@plt>
mov    %eax,-0x64(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x64(%rbp),%edi
mov    -0x60(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
cmpq   $0x0,-0x20(%rbp)
je     126a <log_request+0x11a>
mov    -0x38(%rbp),%rdi
call   1060 <fileno@plt>
mov    %eax,-0x74(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x74(%rbp),%edi
mov    -0x70(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
cmpq   $0x0,-0x28(%rbp)
je     12a6 <log_request+0x156>
mov    -0x38(%rbp),%rdi
call   1060 <fileno@plt>
mov    %eax,-0x84(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x28(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x84(%rbp),%edi
mov    -0x80(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
cmpq   $0x0,-0x30(%rbp)
je     12e8 <log_request+0x198>
mov    -0x38(%rbp),%rdi
call   1060 <fileno@plt>
mov    %eax,-0x94(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    -0x30(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x94(%rbp),%edi
mov    -0x90(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
cmpq   $0x0,0x10(%rbp)
je     132a <log_request+0x1da>
mov    -0x38(%rbp),%rdi
call   1060 <fileno@plt>
mov    %eax,-0xa4(%rbp)
mov    0x10(%rbp),%rax
mov    %rax,-0xa0(%rbp)
mov    0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0xa4(%rbp),%edi
mov    -0xa0(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
cmpq   $0x0,0x18(%rbp)
je     136c <log_request+0x21c>
mov    -0x38(%rbp),%rdi
call   1060 <fileno@plt>
mov    %eax,-0xb4(%rbp)
mov    0x18(%rbp),%rax
mov    %rax,-0xb0(%rbp)
mov    0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0xb4(%rbp),%edi
mov    -0xb0(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    -0x38(%rbp),%rdi
call   1040 <fclose@plt>
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<log_request>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9,0x18(%rsp)
mov    %r8,0x10(%rsp)
mov    %rcx,0x8(%rsp)
mov    %rdx,%rbx
mov    %rsi,%r15
mov    %rdi,%r12
mov    0x68(%rsp),%r13
mov    0x60(%rsp),%rax
mov    %rax,0x20(%rsp)
lea    0xe74(%rip),%rdi
lea    0xe77(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r14
test   %r12,%r12
je     11c6 <log_request+0x76>
mov    %r14,%rdi
call   1060 <fileno@plt>
mov    %r13,%rbp
mov    %eax,%r13d
mov    %r12,%rdi
call   1050 <strlen@plt>
mov    %r13d,%edi
mov    %rbp,%r13
mov    %r12,%rsi
mov    %eax,%edx
call   1030 <write@plt>
test   %r15,%r15
je     11e9 <log_request+0x99>
mov    %r14,%rdi
call   1060 <fileno@plt>
mov    %eax,%ebp
mov    %r15,%rdi
call   1050 <strlen@plt>
mov    %ebp,%edi
mov    %r15,%rsi
mov    %eax,%edx
call   1030 <write@plt>
test   %rbx,%rbx
mov    0x10(%rsp),%r12
je     1211 <log_request+0xc1>
mov    %r14,%rdi
call   1060 <fileno@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    0x8(%rsp),%rbx
test   %rbx,%rbx
mov    0x18(%rsp),%r15
je     123e <log_request+0xee>
mov    %r14,%rdi
call   1060 <fileno@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <write@plt>
test   %r12,%r12
mov    0x20(%rsp),%rbx
je     1266 <log_request+0x116>
mov    %r14,%rdi
call   1060 <fileno@plt>
mov    %eax,%ebp
mov    %r12,%rdi
call   1050 <strlen@plt>
mov    %ebp,%edi
mov    %r12,%rsi
mov    %eax,%edx
call   1030 <write@plt>
test   %r15,%r15
je     1289 <log_request+0x139>
mov    %r14,%rdi
call   1060 <fileno@plt>
mov    %eax,%ebp
mov    %r15,%rdi
call   1050 <strlen@plt>
mov    %ebp,%edi
mov    %r15,%rsi
mov    %eax,%edx
call   1030 <write@plt>
test   %rbx,%rbx
je     12ac <log_request+0x15c>
mov    %r14,%rdi
call   1060 <fileno@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <write@plt>
test   %r13,%r13
je     12cf <log_request+0x17f>
mov    %r14,%rdi
call   1060 <fileno@plt>
mov    %eax,%ebp
mov    %r13,%rdi
call   1050 <strlen@plt>
mov    %ebp,%edi
mov    %r13,%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    %r14,%rdi
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <fclose@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"proxy.log\00"
@.str.1 = [2 x i8] c"a\00"
define void @log_request(i8* %0, i8* %1, i8* %2, i8* %3, i8* %4, i8* %5, i8* %6, i8* %7) {
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca i32*
store i8* %0, i8** %9
store i8* %1, i8** %10
store i8* %2, i8** %11
store i8* %3, i8** %12
store i8* %4, i8** %13
store i8* %5, i8** %14
store i8* %6, i8** %15
store i8* %7, i8** %16
%18 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %18, i32** %17
%19 = load i8*, i8** %9
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %28
21: ; preds = %8
%22 = load i32*, i32** %17
%23 = call i32 @fileno(i32* %22)
%24 = load i8*, i8** %9
%25 = load i8*, i8** %9
%26 = call i32 @strlen(i8* %25)
%27 = call i32 @write(i32 %23, i8* %24, i32 %26)
br label %28
28: ; preds = %21, %8
%29 = load i8*, i8** %10
%30 = icmp ne i8* %29, null
br i1 %30, label %31, label %38
31: ; preds = %28
%32 = load i32*, i32** %17
%33 = call i32 @fileno(i32* %32)
%34 = load i8*, i8** %10
%35 = load i8*, i8** %10
%36 = call i32 @strlen(i8* %35)
%37 = call i32 @write(i32 %33, i8* %34, i32 %36)
br label %38
38: ; preds = %31, %28
%39 = load i8*, i8** %11
%40 = icmp ne i8* %39, null
br i1 %40, label %41, label %48
41: ; preds = %38
%42 = load i32*, i32** %17
%43 = call i32 @fileno(i32* %42)
%44 = load i8*, i8** %11
%45 = load i8*, i8** %11
%46 = call i32 @strlen(i8* %45)
%47 = call i32 @write(i32 %43, i8* %44, i32 %46)
br label %48
48: ; preds = %41, %38
%49 = load i8*, i8** %12
%50 = icmp ne i8* %49, null
br i1 %50, label %51, label %58
51: ; preds = %48
%52 = load i32*, i32** %17
%53 = call i32 @fileno(i32* %52)
%54 = load i8*, i8** %12
%55 = load i8*, i8** %12
%56 = call i32 @strlen(i8* %55)
%57 = call i32 @write(i32 %53, i8* %54, i32 %56)
br label %58
58: ; preds = %51, %48
%59 = load i8*, i8** %13
%60 = icmp ne i8* %59, null
br i1 %60, label %61, label %68
61: ; preds = %58
%62 = load i32*, i32** %17
%63 = call i32 @fileno(i32* %62)
%64 = load i8*, i8** %13
%65 = load i8*, i8** %13
%66 = call i32 @strlen(i8* %65)
%67 = call i32 @write(i32 %63, i8* %64, i32 %66)
br label %68
68: ; preds = %61, %58
%69 = load i8*, i8** %14
%70 = icmp ne i8* %69, null
br i1 %70, label %71, label %78
71: ; preds = %68
%72 = load i32*, i32** %17
%73 = call i32 @fileno(i32* %72)
%74 = load i8*, i8** %14
%75 = load i8*, i8** %14
%76 = call i32 @strlen(i8* %75)
%77 = call i32 @write(i32 %73, i8* %74, i32 %76)
br label %78
78: ; preds = %71, %68
%79 = load i8*, i8** %15
%80 = icmp ne i8* %79, null
br i1 %80, label %81, label %88
81: ; preds = %78
%82 = load i32*, i32** %17
%83 = call i32 @fileno(i32* %82)
%84 = load i8*, i8** %15
%85 = load i8*, i8** %15
%86 = call i32 @strlen(i8* %85)
%87 = call i32 @write(i32 %83, i8* %84, i32 %86)
br label %88
88: ; preds = %81, %78
%89 = load i8*, i8** %16
%90 = icmp ne i8* %89, null
br i1 %90, label %91, label %98
91: ; preds = %88
%92 = load i32*, i32** %17
%93 = call i32 @fileno(i32* %92)
%94 = load i8*, i8** %16
%95 = load i8*, i8** %16
%96 = call i32 @strlen(i8* %95)
%97 = call i32 @write(i32 %93, i8* %94, i32 %96)
br label %98
98: ; preds = %91, %88
%99 = load i32*, i32** %17
%100 = call i32 @fclose(i32* %99)
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"proxy.log\00"
@.str.1 = [2 x i8] c"a\00"
define void @log_request(i8* %0, i8* %1, i8* %2, i8* %3, i8* %4, i8* %5, i8* %6, i8* %7) {
%9 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i8* %0, null
br i1 %10, label %15, label %11
11: ; preds = %8
%12 = tail call i32 @fileno(i32* %9)
%13 = tail call i32 @strlen(i8* %0)
%14 = tail call i32 @write(i32 %12, i8* %0, i32 %13)
br label %15
15: ; preds = %11, %8
%16 = icmp eq i8* %1, null
br i1 %16, label %21, label %17
17: ; preds = %15
%18 = tail call i32 @fileno(i32* %9)
%19 = tail call i32 @strlen(i8* %1)
%20 = tail call i32 @write(i32 %18, i8* %1, i32 %19)
br label %21
21: ; preds = %17, %15
%22 = icmp eq i8* %2, null
br i1 %22, label %27, label %23
23: ; preds = %21
%24 = tail call i32 @fileno(i32* %9)
%25 = tail call i32 @strlen(i8* %2)
%26 = tail call i32 @write(i32 %24, i8* %2, i32 %25)
br label %27
27: ; preds = %23, %21
%28 = icmp eq i8* %3, null
br i1 %28, label %33, label %29
29: ; preds = %27
%30 = tail call i32 @fileno(i32* %9)
%31 = tail call i32 @strlen(i8* %3)
%32 = tail call i32 @write(i32 %30, i8* %3, i32 %31)
br label %33
33: ; preds = %29, %27
%34 = icmp eq i8* %4, null
br i1 %34, label %39, label %35
35: ; preds = %33
%36 = tail call i32 @fileno(i32* %9)
%37 = tail call i32 @strlen(i8* %4)
%38 = tail call i32 @write(i32 %36, i8* %4, i32 %37)
br label %39
39: ; preds = %35, %33
%40 = icmp eq i8* %5, null
br i1 %40, label %45, label %41
41: ; preds = %39
%42 = tail call i32 @fileno(i32* %9)
%43 = tail call i32 @strlen(i8* %5)
%44 = tail call i32 @write(i32 %42, i8* %5, i32 %43)
br label %45
45: ; preds = %41, %39
%46 = icmp eq i8* %6, null
br i1 %46, label %51, label %47
47: ; preds = %45
%48 = tail call i32 @fileno(i32* %9)
%49 = tail call i32 @strlen(i8* %6)
%50 = tail call i32 @write(i32 %48, i8* %6, i32 %49)
br label %51
51: ; preds = %47, %45
%52 = icmp eq i8* %7, null
br i1 %52, label %57, label %53
53: ; preds = %51
%54 = tail call i32 @fileno(i32* %9)
%55 = tail call i32 @strlen(i8* %7)
%56 = tail call i32 @write(i32 %54, i8* %7, i32 %55)
br label %57
57: ; preds = %53, %51
%58 = tail call i32 @fclose(i32* %9)
ret void
}