#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*/ SEEK_END;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputc(int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
void completetempfile(int trash) {
  FILE *temp;
  temp = fopen("temp.txt", "r+");
  fseek(temp, 0, SEEK_END);
  for (trash = trash; trash >= 1; trash--) {
    fputc('0', temp);
  }
  fclose(temp);
}


x86 assembly (clang, -O0):
<completetempfile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    0xeae(%rip),%rdi
lea    0xeb0(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e7b(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1050 <fseek@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
cmpl   $0x1,-0x4(%rbp)
jl     11a2 <completetempfile+0x62>
mov    -0x10(%rbp),%rsi
mov    $0x30,%edi
call   1040 <fputc@plt>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
jmp    117c <completetempfile+0x3c>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<completetempfile>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
lea    0xeb3(%rip),%rdi
lea    0xeb5(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r14
mov    0x2e85(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1050 <fseek@plt>
test   %ebx,%ebx
jle    1195 <completetempfile+0x55>
add    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    $0x30,%edi
mov    %r14,%rsi
call   1040 <fputc@plt>
add    $0xffffffff,%ebx
cmp    $0x1,%ebx
ja     1180 <completetempfile+0x40>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <fclose@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"temp.txt\00"
@.str.1 = [3 x i8] c"r+\00"
@SEEK_END = global i32 0
define void @completetempfile(i32 %0) {
%2 = alloca i32
%3 = alloca i32*
store i32 %0, i32* %2
%4 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %4, i32** %3
%5 = load i32*, i32** %3
%6 = load i32, i32* @SEEK_END
%7 = call i32 @fseek(i32* %5, i32 0, i32 %6)
%8 = load i32, i32* %2
store i32 %8, i32* %2
br label %9
9: ; preds = %15, %1
%10 = load i32, i32* %2
%11 = icmp sge i32 %10, 1
br i1 %11, label %12, label %18
12: ; preds = %9
%13 = load i32*, i32** %3
%14 = call i32 @fputc(i32 48, i32* %13)
br label %15
15: ; preds = %12
%16 = load i32, i32* %2
%17 = add nsw i32 %16, -1
store i32 %17, i32* %2
br label %9
18: ; preds = %9
%19 = load i32*, i32** %3
%20 = call i32 @fclose(i32* %19)
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"temp.txt\00"
@.str.1 = [3 x i8] c"r+\00"
@SEEK_END = global i32 0
define void @completetempfile(i32 %0) {
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%3 = load i32, i32* @SEEK_END
%4 = tail call i32 @fseek(i32* %2, i32 0, i32 %3)
%5 = icmp sgt i32 %0, 0
br i1 %5, label %6, label %11
6: ; preds = %1, %6
%7 = phi i32 [ %9, %6 ], [ %0, %1 ]
%8 = tail call i32 @fputc(i32 48, i32* %2)
%9 = add nsw i32 %7, -1
%10 = icmp ugt i32 %7, 1
br i1 %10, label %6, label %11
11: ; preds = %6, %1
%12 = tail call i32 @fclose(i32* %2)
ret void
}