#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*/ fprintf(int /*<<< orphan*/ *, char *, unsigned int, double);
int /*<<< orphan*/ printf(char *);
void incAndLogFaultCounter(void *fid, unsigned int *counter, double time) {
  FILE *fptr = (FILE *)fid;
  (*counter)++;
  if (fptr == NULL) {
    printf("Cannot write to the file 'sldemo_lct_fault.log'\n");
    return;
  }
  (void)fprintf(fptr, "Fault %d detected at %g s\n", *counter, time);
}


x86 assembly (clang, -O0):
<incAndLogFaultCounter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
cmpq   $0x0,-0x20(%rbp)
jne    1164 <incAndLogFaultCounter+0x44>
lea    0xea6(%rip),%rdi
call   1030 <printf@plt>
jmp    117f <incAndLogFaultCounter+0x5f>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%edx
movsd  -0x18(%rbp),%xmm0
lea    0xeb7(%rip),%rsi
call   1040 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<incAndLogFaultCounter>:
mov    (%rsi),%edx
add    $0x1,%edx
mov    %edx,(%rsi)
test   %rdi,%rdi
je     1138 <incAndLogFaultCounter+0x18>
lea    0xecd(%rip),%rsi
jmp    1040 <fprintf@plt>
lea    0xedc(%rip),%rdi
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [49 x i8] c"Cannot write to the file 'sldemo_lct_fault.log'\0A\00"
@.str.1 = [27 x i8] c"Fault %d detected at %g s\0A\00"
define void @incAndLogFaultCounter(i8* %0, i32* %1, double %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca double
%7 = alloca i32*
store i8* %0, i8** %4
store i32* %1, i32** %5
store double %2, double* %6
%8 = load i8*, i8** %4
%9 = bitcast i8* %8 to i32*
store i32* %9, i32** %7
%10 = load i32*, i32** %5
%11 = load i32, i32* %10
%12 = add i32 %11, 1
store i32 %12, i32* %10
%13 = load i32*, i32** %7
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %17
15: ; preds = %3
%16 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
br label %23
17: ; preds = %3
%18 = load i32*, i32** %7
%19 = load i32*, i32** %5
%20 = load i32, i32* %19
%21 = load double, double* %6
%22 = call i32 @fprintf(i32* %18, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %20, double %21)
br label %23
23: ; preds = %17, %15
ret void
}

LLVM IR (-O2):
@.str.1 = [27 x i8] c"Fault %d detected at %g s\0A\00"
@str = [48 x i8] c"Cannot write to the file 'sldemo_lct_fault.log'\00"
define void @incAndLogFaultCounter(i8* %0, i32* nocapture %1, double %2) {
%4 = load i32, i32* %1
%5 = add i32 %4, 1
store i32 %5, i32* %1
%6 = icmp eq i8* %0, null
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str, i64 0, i64 0))
br label %12
9: ; preds = %3
%10 = bitcast i8* %0 to i32*
%11 = tail call i32 @fprintf(i32* %10, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %5, double %2)
br label %12
12: ; preds = %9, %7
ret void
}