#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*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, size_t, float const);
int /*<<< orphan*/ perror(char const *);
void dumpProbs(const char *fn, const float *days, const int maxdays) {
  FILE *fp = fopen(fn, "wt");
  if (fp) {
    for (size_t i = 0; i < maxdays; i++) {
      fprintf(fp, "%zd\t%f\n", i, days[i]);
    }
    fclose(fp);
  } else {
    perror(fn);
    exit(1);
  }
}


x86 assembly (clang, -O0):
<dumpProbs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe92(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11db <dumpProbs+0x8b>
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmp    %rcx,%rax
jae    11cd <dumpProbs+0x7d>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
lea    0xe4c(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    118a <dumpProbs+0x3a>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
jmp    11ee <dumpProbs+0x9e>
mov    -0x8(%rbp),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dumpProbs>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %edx,%ebx
mov    %rsi,%r14
mov    %rdi,%r12
lea    0xe98(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     11be <dumpProbs+0x6e>
mov    %rax,%r15
test   %ebx,%ebx
je     11ad <dumpProbs+0x5d>
movslq %ebx,%r13
xor    %ebx,%ebx
lea    0xe7e(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nop
movss  (%r14,%rbx,4),%xmm0
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1040 <fprintf@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1190 <dumpProbs+0x40>
mov    %r15,%rdi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <fclose@plt>
mov    %r12,%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"wt\00"
@.str.1 = [8 x i8] c"%zd\09%f\0A\00"
define void @dumpProbs(i8* %0, float* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca float*
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i64
store i8* %0, i8** %4
store float* %1, float** %5
store i32 %2, i32* %6
%9 = load i8*, i8** %4
%10 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %10, i32** %7
%11 = load i32*, i32** %7
%12 = icmp ne i32* %11, null
br i1 %12, label %13, label %33
13: ; preds = %3
store i64 0, i64* %8
br label %14
14: ; preds = %27, %13
%15 = load i64, i64* %8
%16 = load i32, i32* %6
%17 = sext i32 %16 to i64
%18 = icmp ult i64 %15, %17
br i1 %18, label %19, label %30
19: ; preds = %14
%20 = load i32*, i32** %7
%21 = load i64, i64* %8
%22 = load float*, float** %5
%23 = load i64, i64* %8
%24 = getelementptr inbounds float, float* %22, i64 %23
%25 = load float, float* %24
%26 = call i32 @fprintf(i32* %20, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i64 %21, float %25)
br label %27
27: ; preds = %19
%28 = load i64, i64* %8
%29 = add i64 %28, 1
store i64 %29, i64* %8
br label %14
30: ; preds = %14
%31 = load i32*, i32** %7
%32 = call i32 @fclose(i32* %31)
br label %37
33: ; preds = %3
%34 = load i8*, i8** %4
%35 = call i32 @perror(i8* %34)
%36 = call i32 @exit(i32 1)
unreachable
37: ; preds = %30
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"wt\00"
@.str.1 = [8 x i8] c"%zd\09%f\0A\00"
define void @dumpProbs(i8* nocapture %0, float* nocapture %1, i32 %2) {
%4 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %19, label %6
6: ; preds = %3
%7 = icmp eq i32 %2, 0
br i1 %7, label %10, label %8
8: ; preds = %6
%9 = sext i32 %2 to i64
br label %12
10: ; preds = %12, %6
%11 = tail call i32 @fclose(i32* %4)
ret void
12: ; preds = %8, %12
%13 = phi i64 [ %17, %12 ], [ 0, %8 ]
%14 = getelementptr inbounds float, float* %1, i64 %13
%15 = load float, float* %14
%16 = tail call i32 @fprintf(i32* %4, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i64 %13, float %15)
%17 = add nuw i64 %13, 1
%18 = icmp eq i64 %17, %9
br i1 %18, label %10, label %12
19: ; preds = %3
%20 = tail call i32 @perror(i8* %0)
%21 = tail call i32 @exit(i32 1)
unreachable
}