#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 *, char *);
int /*<<< orphan*/ sprintf(char *, char *, ...);
void WriteToFile(char *unit, int cuid, int time, int cnt) {
  FILE *fp;
  char fileName[50];
  char buff[50];
  sprintf(buff, "%d, %d\n", cnt, time);
  sprintf(fileName, "%s_%d.tim", unit, cuid);
  fp = fopen(fileName, "a");
  fprintf(fp, "%s", buff);
  fclose(fp);
}


x86 assembly (clang, -O0):
<WriteToFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
lea    -0xa0(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe94(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
lea    -0x60(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0xc(%rbp),%ecx
lea    0xe83(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
lea    -0x60(%rbp),%rdi
lea    0xe7b(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0xa0(%rbp),%rdx
lea    0xe62(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<WriteToFile>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x78,%rsp
mov    %edx,%eax
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0xea8(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
mov    %ecx,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1060 <sprintf@plt>
lea    0xe98(%rip),%rsi
lea    0x40(%rsp),%r15
mov    %r15,%rdi
mov    %rbx,%rdx
mov    %ebp,%ecx
xor    %eax,%eax
call   1060 <sprintf@plt>
lea    0xe87(%rip),%rsi
mov    %r15,%rdi
call   1050 <fopen@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
call   1040 <fputs@plt>
mov    %rbx,%rdi
add    $0x78,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fclose@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"%d, %d\0A\00"
@.str.1 = [10 x i8] c"%s_%d.tim\00"
@.str.2 = [2 x i8] c"a\00"
@.str.3 = [3 x i8] c"%s\00"
define void @WriteToFile(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
%10 = alloca [50 x i8]
%11 = alloca [50 x i8]
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%12 = getelementptr inbounds [50 x i8], [50 x i8]* %11, i64 0, i64 0
%13 = load i32, i32* %8
%14 = load i32, i32* %7
%15 = call i32 (i8*, i8*, ...) @sprintf(i8* %12, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %13, i32 %14)
%16 = getelementptr inbounds [50 x i8], [50 x i8]* %10, i64 0, i64 0
%17 = load i8*, i8** %5
%18 = load i32, i32* %6
%19 = call i32 (i8*, i8*, ...) @sprintf(i8* %16, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %17, i32 %18)
%20 = getelementptr inbounds [50 x i8], [50 x i8]* %10, i64 0, i64 0
%21 = call i32* @fopen(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %21, i32** %9
%22 = load i32*, i32** %9
%23 = getelementptr inbounds [50 x i8], [50 x i8]* %11, i64 0, i64 0
%24 = call i32 @fprintf(i32* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %23)
%25 = load i32*, i32** %9
%26 = call i32 @fclose(i32* %25)
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"%d, %d\0A\00"
@.str.1 = [10 x i8] c"%s_%d.tim\00"
@.str.2 = [2 x i8] c"a\00"
define void @WriteToFile(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca [50 x i8]
%6 = alloca [50 x i8]
%7 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%8 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 0
%9 = call i32 (i8*, i8*, ...) @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %3, i32 %2)
%10 = call i32 (i8*, i8*, ...) @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32 %1)
%11 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @fputs(i8* %8, i32* %11)
%13 = tail call i32 @fclose(i32* %11)
ret void
}