#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*/ *const);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *const, char *, int);
int /*<<< orphan*/ printf(char *, char const *);
int /*<<< orphan*/ set_fan_auto(int);
int /*<<< orphan*/ sleep(int);
int temp_max();
int main(const int argc, const char **const argv) {
  if (argc < 2) {
    printf("usage: %s <filename>\n", argv[0]);
    return 0;
  }
  while (1) {
    int temp = temp_max();
    set_fan_auto(70000 > temp);
    FILE *const file = fopen(argv[1], "wb");
    fprintf(file, "%i\n", temp / 1000);
    fclose(file);
    sleep(1);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11ab <main+0x3b>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe62(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret
jmp    11b0 <main+0x40>
mov    $0x0,%al
call   1050 <temp_max@plt>
mov    %eax,-0x14(%rbp)
mov    $0x11170,%eax
cmp    -0x14(%rbp),%eax
setg   %al
and    $0x1,%al
mov    %al,-0x21(%rbp)
movzbl %al,%edi
call   1080 <set_fan_auto@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe35(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
lea    0xe17(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    $0x1,%edi
call   1090 <sleep@plt>
jmp    11b0 <main+0x40>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r12
cmp    $0x2,%edi
jge    119b <main+0x2b>
mov    (%r12),%rsi
lea    0xe75(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe74(%rip),%r14
lea    0xe70(%rip),%r15
nopl   0x0(%rax)
xor    %eax,%eax
call   1050 <temp_max@plt>
mov    %eax,%ebp
xor    %edi,%edi
cmp    $0x11170,%eax
setl   %dil
call   1080 <set_fan_auto@plt>
mov    0x8(%r12),%rdi
mov    %r14,%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
movslq %ebp,%rax
imul   $0x10624dd3,%rax,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x26,%rdx
add    %eax,%edx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    $0x1,%edi
call   1090 <sleep@plt>
jmp    11b0 <main+0x40>

LLVM IR (-O0):
@.str = [22 x i8] c"usage: %s <filename>\0A\00"
@.str.1 = [3 x i8] c"wb\00"
@.str.2 = [4 x i8] c"%i\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %13)
ret i32 0
15: ; preds = %2
br label %16
16: ; preds = %15, %16
%17 = call i32 (...) @temp_max()
store i32 %17, i32* %6
%18 = load i32, i32* %6
%19 = icmp sgt i32 70000, %18
%20 = zext i1 %19 to i32
%21 = call i32 @set_fan_auto(i32 %20)
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32* @fopen(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %25, i32** %7
%26 = load i32*, i32** %7
%27 = load i32, i32* %6
%28 = sdiv i32 %27, 1000
%29 = call i32 @fprintf(i32* %26, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %28)
%30 = load i32*, i32** %7
%31 = call i32 @fclose(i32* %30)
%32 = call i32 @sleep(i32 1)
br label %16
}

LLVM IR (-O2):
@.str = [22 x i8] c"usage: %s <filename>\0A\00"
@.str.1 = [3 x i8] c"wb\00"
@.str.2 = [4 x i8] c"%i\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
br label %9
6: ; preds = %2
%7 = load i8*, i8** %1
%8 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %7)
ret i32 0
9: ; preds = %4, %9
%10 = tail call i32 (...) @temp_max()
%11 = icmp slt i32 %10, 70000
%12 = zext i1 %11 to i32
%13 = tail call i32 @set_fan_auto(i32 %12)
%14 = load i8*, i8** %5
%15 = tail call i32* @fopen(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%16 = sdiv i32 %10, 1000
%17 = tail call i32 @fprintf(i32* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %16)
%18 = tail call i32 @fclose(i32* %15)
%19 = tail call i32 @sleep(i32 1)
br label %9
}