#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, float *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int put_info(char *path, char *format) {
  FILE *fp = fopen(path, "r");
  if (!fp) {
    fprintf(stderr, "Can't open '%s'.\n", path);
    return EXIT_FAILURE;
  }
  float temp;
  fscanf(fp, "%f", &temp);
  fclose(fp);
  printf(format, temp / 1000);
  printf("\n");
  fflush(stdout);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<put_info>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe89(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11b9 <put_info+0x59>
mov    0x2e4a(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe63(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2e29(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    121e <put_info+0xbe>
mov    -0x20(%rbp),%rdi
lea    0xe54(%rip),%rsi
lea    -0x24(%rbp),%rdx
call   1050 <fscanf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x18(%rbp),%rdi
movss  -0x24(%rbp),%xmm0
movss  0xe19(%rip),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2dc5(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
mov    0x2daf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<put_info>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xe7e(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     11ec <put_info+0x7c>
mov    %rax,%rbx
lea    0xe7e(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %rax,%rdi
call   1060 <fscanf@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
movss  0xc(%rsp),%xmm0
divss  0xe43(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x2df4(%rip),%rax
mov    (%rax),%edi
call   1080 <fflush@plt>
mov    0x2dde(%rip),%rax
jmp    120b <put_info+0x9b>
mov    0x2ded(%rip),%rax
mov    (%rax),%edi
lea    0xe0a(%rip),%rsi
mov    %r15,%rdx
call   1070 <fprintf@plt>
mov    0x2dcd(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [18 x i8] c"Can't open '%s'.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [3 x i8] c"%f\00"
@.str.3 = [2 x i8] c"\0A\00"
@stdout = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @put_info(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca float
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %4
%9 = call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %9, i32** %6
%10 = load i32*, i32** %6
%11 = icmp ne i32* %10, null
br i1 %11, label %17, label %12
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = load i8*, i8** %4
%15 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = load i32, i32* @EXIT_FAILURE
store i32 %16, i32* %3
br label %31
17: ; preds = %2
%18 = load i32*, i32** %6
%19 = call i32 @fscanf(i32* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %7)
%20 = load i32*, i32** %6
%21 = call i32 @fclose(i32* %20)
%22 = load i8*, i8** %5
%23 = load float, float* %7
%24 = fdiv float %23, 1.000000e+03
%25 = fpext float %24 to double
%26 = call i32 (i8*, ...) @printf(i8* %22, double %25)
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%28 = load i32, i32* @stdout
%29 = call i32 @fflush(i32 %28)
%30 = load i32, i32* @EXIT_SUCCESS
store i32 %30, i32* %3
br label %31
31: ; preds = %17, %12
%32 = load i32, i32* %3
ret i32 %32
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [18 x i8] c"Can't open '%s'.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [3 x i8] c"%f\00"
@stdout = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @put_info(i8* %0, i8* nocapture %1) {
%3 = alloca float
%4 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%9 = load i32, i32* @EXIT_FAILURE
br label %22
10: ; preds = %2
%11 = bitcast float* %3 to i8*
%12 = call i32 @fscanf(i32* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %3)
%13 = call i32 @fclose(i32* %4)
%14 = load float, float* %3
%15 = fdiv float %14, 1.000000e+03
%16 = fpext float %15 to double
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %1, double %16)
%18 = call i32 @putchar(i32 10)
%19 = load i32, i32* @stdout
%20 = call i32 @fflush(i32 %19)
%21 = load i32, i32* @EXIT_SUCCESS
br label %22
22: ; preds = %10, %6
%23 = phi i32 [ %21, %10 ], [ %9, %6 ]
ret i32 %23
}