#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 readint(char *);
char *smprintf(char *, ...);
char *gettemperature(void) {
  int c1 = readint("/sys/class/hwmon/hwmon0/device/temp1_input");
  int c2 = readint("/sys/class/hwmon/hwmon0/device/temp1_input");
  if (!(c1 || c2))
    return smprintf("");
  return smprintf("temp: %d/%dC", c1 / 1000, c2 / 1000);
}


x86 assembly (clang, -O0):
<gettemperature>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
call   1040 <readint@plt>
mov    %eax,-0xc(%rbp)
lea    0xec2(%rip),%rdi
call   1040 <readint@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    1171 <gettemperature+0x51>
cmpl   $0x0,-0x10(%rbp)
jne    1171 <gettemperature+0x51>
lea    0xed6(%rip),%rdi
mov    $0x0,%al
call   1030 <smprintf@plt>
mov    %rax,-0x8(%rbp)
jmp    119d <gettemperature+0x7d>
mov    -0xc(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    -0x10(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <smprintf@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gettemperature>:
push   %r14
push   %rbx
push   %rax
lea    0xed5(%rip),%r14
mov    %r14,%rdi
call   1040 <readint@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1040 <readint@plt>
mov    %ebx,%ecx
or     %eax,%ecx
je     1185 <gettemperature+0x65>
movslq %ebx,%rcx
imul   $0x10624dd3,%rcx,%rsi
mov    %rsi,%rcx
shr    $0x3f,%rcx
sar    $0x26,%rsi
add    %ecx,%esi
cltq
imul   $0x10624dd3,%rax,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x26,%rdx
add    %eax,%edx
lea    0xeb4(%rip),%rdi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <smprintf@plt>
lea    0xeab(%rip),%rdi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <smprintf@plt>

LLVM IR (-O0):
@.str = [43 x i8] c"/sys/class/hwmon/hwmon0/device/temp1_input\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [13 x i8] c"temp: %d/%dC\00"
define i8* @gettemperature() {
%1 = alloca i8*
%2 = alloca i32
%3 = alloca i32
%4 = call i32 @readint(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
store i32 %4, i32* %2
%5 = call i32 @readint(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
store i32 %5, i32* %3
%6 = load i32, i32* %2
%7 = icmp ne i32 %6, 0
br i1 %7, label %13, label %8
8: ; preds = %0
%9 = load i32, i32* %3
%10 = icmp ne i32 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %8
%12 = call i8* (i8*, ...) @smprintf(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
store i8* %12, i8** %1
br label %19
13: ; preds = %8, %0
%14 = load i32, i32* %2
%15 = sdiv i32 %14, 1000
%16 = load i32, i32* %3
%17 = sdiv i32 %16, 1000
%18 = call i8* (i8*, ...) @smprintf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %15, i32 %17)
store i8* %18, i8** %1
br label %19
19: ; preds = %13, %11
%20 = load i8*, i8** %1
ret i8* %20
}

LLVM IR (-O2):
@.str = [43 x i8] c"/sys/class/hwmon/hwmon0/device/temp1_input\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [13 x i8] c"temp: %d/%dC\00"
define i8* @gettemperature() {
%1 = tail call i32 @readint(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @readint(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
%3 = icmp ne i32 %1, 0
%4 = icmp ne i32 %2, 0
%5 = select i1 %3, i1 true, i1 %4
br i1 %5, label %8, label %6
6: ; preds = %0
%7 = tail call i8* (i8*, ...) @smprintf(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
br label %12
8: ; preds = %0
%9 = sdiv i32 %1, 1000
%10 = sdiv i32 %2, 1000
%11 = tail call i8* (i8*, ...) @smprintf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %9, i32 %10)
br label %12
12: ; preds = %8, %6
%13 = phi i8* [ %11, %8 ], [ %7, %6 ]
ret i8* %13
}