#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*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int, char *, char *,
                           char *, int, int, double);
int /*<<< orphan*/ strtok(char *, char *);
void fw_log(int id, char *start_time, char *in, char *out, int dim,
            int thread_count, double time) {
  FILE *fp = fopen("log.txt", "a");
  if (fp != NULL) {
    strtok(start_time, "\n");
    fprintf(fp, "%i\t%s\t%s\t%s\t%i\t%i\t%f\n", id, start_time, in, out, dim,
            thread_count, time);
    fclose(fp);
  }
}


x86 assembly (clang, -O0):
<fw_log>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9d,-0x28(%rbp)
movsd  %xmm0,-0x30(%rbp)
lea    0xe95(%rip),%rdi
lea    0xe96(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     11d2 <fw_log+0x92>
mov    -0x10(%rbp),%rdi
lea    0xe8d(%rip),%rsi
call   1060 <strtok@plt>
mov    -0x38(%rbp),%rdi
mov    -0x4(%rbp),%edx
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%r8
mov    -0x20(%rbp),%r9
mov    -0x24(%rbp),%r10d
mov    -0x28(%rbp),%eax
movsd  -0x30(%rbp),%xmm0
lea    0xe4e(%rip),%rsi
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1040 <fprintf@plt>
mov    -0x38(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fw_log>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movsd  %xmm0,0x8(%rsp)
mov    %r9d,%r15d
mov    %r8,0x10(%rsp)
mov    %rcx,%r12
mov    %rdx,%r13
mov    %rsi,%rbp
mov    %edi,%r14d
lea    0xe91(%rip),%rdi
lea    0xe92(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     11d3 <fw_log+0x93>
mov    %rax,%rbx
lea    0xe94(%rip),%rsi
mov    %rbp,%rdi
call   1060 <strtok@plt>
lea    0xe71(%rip),%rsi
mov    %rbx,%rdi
mov    %r14d,%edx
mov    %rbp,%rcx
mov    %r13,%r8
mov    %r12,%r9
movsd  0x8(%rsp),%xmm0
push   %r15
push   0x18(%rsp)
call   1040 <fprintf@plt>
add    $0x10,%rsp
mov    %rbx,%rdi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fclose@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"log.txt\00"
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [22 x i8] c"%i\09%s\09%s\09%s\09%i\09%i\09%f\0A\00"
define void @fw_log(i32 %0, i8* %1, i8* %2, i8* %3, i32 %4, i32 %5, double %6) {
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca double
%15 = alloca i32*
store i32 %0, i32* %8
store i8* %1, i8** %9
store i8* %2, i8** %10
store i8* %3, i8** %11
store i32 %4, i32* %12
store i32 %5, i32* %13
store double %6, double* %14
%16 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %16, i32** %15
%17 = load i32*, i32** %15
%18 = icmp ne i32* %17, null
br i1 %18, label %19, label %33
19: ; preds = %7
%20 = load i8*, i8** %9
%21 = call i32 @strtok(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%22 = load i32*, i32** %15
%23 = load i32, i32* %8
%24 = load i8*, i8** %9
%25 = load i8*, i8** %10
%26 = load i8*, i8** %11
%27 = load i32, i32* %12
%28 = load i32, i32* %13
%29 = load double, double* %14
%30 = call i32 @fprintf(i32* %22, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %23, i8* %24, i8* %25, i8* %26, i32 %27, i32 %28, double %29)
%31 = load i32*, i32** %15
%32 = call i32 @fclose(i32* %31)
br label %33
33: ; preds = %19, %7
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"log.txt\00"
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [22 x i8] c"%i\09%s\09%s\09%s\09%i\09%i\09%f\0A\00"
define void @fw_log(i32 %0, i8* %1, i8* %2, i8* %3, i32 %4, i32 %5, double %6) {
%8 = tail call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %14, label %10
10: ; preds = %7
%11 = tail call i32 @strtok(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%12 = tail call i32 @fprintf(i32* %8, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %0, i8* %1, i8* %2, i8* %3, i32 %4, i32 %5, double %6)
%13 = tail call i32 @fclose(i32* %8)
br label %14
14: ; preds = %10, %7
ret void
}