#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 */

/* Variables and functions */
int atof(char *);
char *readfile(char *, char *);
char *smprintf(char *, ...);
char *get_temp(char *base, char *sensor) {
  char *co;
  co = readfile(base, sensor);
  if (co == NULL)
    return smprintf("");
  return smprintf("%02.0f C", atof(co) / 1000);
}


x86 assembly (clang, -O0):
<get_temp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <readfile@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1173 <get_temp+0x43>
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <smprintf@plt>
mov    %rax,-0x8(%rbp)
jmp    1198 <get_temp+0x68>
mov    -0x20(%rbp),%rdi
call   1040 <atof@plt>
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1030 <smprintf@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_temp>:
push   %rax
call   1050 <readfile@plt>
test   %rax,%rax
je     1168 <get_temp+0x38>
mov    %rax,%rdi
call   1040 <atof@plt>
cltq
imul   $0x10624dd3,%rax,%rsi
mov    %rsi,%rax
shr    $0x3f,%rax
sar    $0x26,%rsi
add    %eax,%esi
lea    0xea0(%rip),%rdi
xor    %eax,%eax
pop    %rcx
jmp    1030 <smprintf@plt>
lea    0xe99(%rip),%rdi
xor    %eax,%eax
pop    %rcx
jmp    1030 <smprintf@plt>

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [9 x i8] c"%02.0f C\00"
define i8* @get_temp(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %4
%8 = load i8*, i8** %5
%9 = call i8* @readfile(i8* %7, i8* %8)
store i8* %9, i8** %6
%10 = load i8*, i8** %6
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i8* (i8*, ...) @smprintf(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i8* %13, i8** %3
br label %19
14: ; preds = %2
%15 = load i8*, i8** %6
%16 = call i32 @atof(i8* %15)
%17 = sdiv i32 %16, 1000
%18 = call i8* (i8*, ...) @smprintf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %17)
store i8* %18, i8** %3
br label %19
19: ; preds = %14, %12
%20 = load i8*, i8** %3
ret i8* %20
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [9 x i8] c"%02.0f C\00"
define i8* @get_temp(i8* %0, i8* %1) {
%3 = tail call i8* @readfile(i8* %0, i8* %1)
%4 = icmp eq i8* %3, null
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i8* (i8*, ...) @smprintf(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %11
7: ; preds = %2
%8 = tail call i32 @atof(i8* %3)
%9 = sdiv i32 %8, 1000
%10 = tail call i8* (i8*, ...) @smprintf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %9)
br label %11
11: ; preds = %7, %5
%12 = phi i8* [ %6, %5 ], [ %10, %7 ]
ret i8* %12
}