#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 int32_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char const *, ...);
int /*<<< orphan*/ puts(char *);
void print_tpv_value(const char *name, const char *format, const int32_t value,
                     const int32_t scale_factor) {
  printf("%s: ", name);
  if ((0x7FFFFFFF) != value) {
    printf(format, (double)value / scale_factor);
  } else {
    puts("INVALID");
  }
}


x86 assembly (clang, -O0):
<print_tpv_value>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xebf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x7fffffff,%eax
cmp    -0x14(%rbp),%eax
je     1174 <print_tpv_value+0x54>
mov    -0x10(%rbp),%rdi
cvtsi2sdl -0x14(%rbp),%xmm0
cvtsi2sdl -0x18(%rbp),%xmm1
divsd  %xmm1,%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
jmp    1180 <print_tpv_value+0x60>
lea    0xe8a(%rip),%rdi
call   1030 <puts@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_tpv_value>:
push   %rbp
push   %r14
push   %rbx
mov    %ecx,%ebp
mov    %edx,%ebx
mov    %rsi,%r14
mov    %rdi,%rsi
lea    0xecb(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x7fffffff,%ebx
jne    1154 <print_tpv_value+0x34>
lea    0xeba(%rip),%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <puts@plt>
cvtsi2sd %ebx,%xmm0
cvtsi2sd %ebp,%xmm1
divsd  %xmm1,%xmm0
mov    %r14,%rdi
mov    $0x1,%al
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"%s: \00"
@.str.1 = [8 x i8] c"INVALID\00"
define void @print_tpv_value(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%9 = load i8*, i8** %5
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = load i32, i32* %7
%12 = icmp ne i32 2147483647, %11
br i1 %12, label %13, label %21
13: ; preds = %4
%14 = load i8*, i8** %6
%15 = load i32, i32* %7
%16 = sitofp i32 %15 to double
%17 = load i32, i32* %8
%18 = sitofp i32 %17 to double
%19 = fdiv double %16, %18
%20 = call i32 (i8*, ...) @printf(i8* %14, double %19)
br label %23
21: ; preds = %4
%22 = call i32 @puts(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %23
23: ; preds = %21, %13
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"%s: \00"
@.str.1 = [8 x i8] c"INVALID\00"
define void @print_tpv_value(i8* %0, i8* nocapture %1, i32 %2, i32 %3) {
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %0)
%6 = icmp eq i32 %2, 2147483647
br i1 %6, label %12, label %7
7: ; preds = %4
%8 = sitofp i32 %2 to double
%9 = sitofp i32 %3 to double
%10 = fdiv double %8, %9
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %1, double %10)
br label %14
12: ; preds = %4
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %14
14: ; preds = %12, %7
ret void
}