#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 /*<<< orphan*/ printf(char *, char *, char *);
int /*<<< orphan*/ snprintf(char *, int, char *, ...);
int strlen(char *);
void print(char *input, double res) {
  char a[100];
  int i;
  snprintf(a, 100, "%f", res);
  i = strlen(a) - 1;
  while (a[i] == '0' && i > 0) {
    i--;
  }
  if (a[i] == '.') {
    i--;
  }
  i += 2;
  char sres[i];
  snprintf(sres, i, "%s", a);
  printf("%s%s\n", input, sres);
}


x86 assembly (clang, -O0):
<print>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
lea    -0x80(%rbp),%rdi
movsd  -0x10(%rbp),%xmm0
mov    $0x64,%esi
lea    0xea7(%rip),%rdx
mov    $0x1,%al
call   1050 <snprintf@plt>
lea    -0x80(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x84(%rbp)
movslq -0x84(%rbp),%rax
movsbl -0x80(%rbp,%rax,1),%ecx
xor    %eax,%eax
cmp    $0x30,%ecx
mov    %al,-0x99(%rbp)
jne    119f <print+0x6f>
cmpl   $0x0,-0x84(%rbp)
setg   %al
mov    %al,-0x99(%rbp)
mov    -0x99(%rbp),%al
test   $0x1,%al
jne    11b2 <print+0x82>
jmp    11c6 <print+0x96>
mov    -0x84(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x84(%rbp)
jmp    1172 <print+0x42>
movslq -0x84(%rbp),%rax
movsbl -0x80(%rbp,%rax,1),%eax
cmp    $0x2e,%eax
jne    11ea <print+0xba>
mov    -0x84(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x84(%rbp)
mov    -0x84(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x84(%rbp)
mov    -0x84(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x90(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0xa8(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x98(%rbp)
mov    -0x84(%rbp),%esi
lea    -0x80(%rbp),%rcx
lea    0xdc7(%rip),%rdx
mov    $0x0,%al
call   1050 <snprintf@plt>
mov    -0xa8(%rbp),%rdx
mov    -0x8(%rbp),%rsi
lea    0xdb1(%rip),%rdi
call   1040 <printf@plt>
mov    -0x90(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
sub    $0x68,%rsp
mov    %rdi,%r14
lea    0xeb9(%rip),%rdx
lea    -0x80(%rbp),%rbx
mov    %rbx,%rdi
mov    $0x64,%esi
mov    $0x1,%al
call   1050 <snprintf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
movslq %eax,%rdx
cs nopw 0x0(%rax,%rax,1)
nop
lea    -0x1(%rdx),%rax
movzbl -0x81(%rbp,%rdx,1),%ecx
ff
cmp    $0x30,%cl
jne    118a <print+0x5a>
cmp    $0x1,%rdx
mov    %rax,%rdx
jg     1170 <print+0x40>
lea    -0x1(%rax),%esi
cmp    $0x2e,%cl
cmovne %eax,%esi
mov    %rsp,%r15
add    $0x2,%esi
lea    0xf(%rsi),%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%rbx
sub    %rax,%rbx
mov    %rbx,%rsp
lea    0xe52(%rip),%rdx
lea    -0x80(%rbp),%rcx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <snprintf@plt>
lea    0xe40(%rip),%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1040 <printf@plt>
mov    %r15,%rsp
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%f\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [6 x i8] c"%s%s\0A\00"
define void @print(i8* %0, double %1) {
%3 = alloca i8*
%4 = alloca double
%5 = alloca [100 x i8]
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
store i8* %0, i8** %3
store double %1, double* %4
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%10 = load double, double* %4
%11 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %9, i32 100, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), double %10)
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%13 = call i32 @strlen(i8* %12)
%14 = sub nsw i32 %13, 1
store i32 %14, i32* %6
br label %15
15: ; preds = %27, %2
%16 = load i32, i32* %6
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 48
br i1 %21, label %22, label %25
22: ; preds = %15
%23 = load i32, i32* %6
%24 = icmp sgt i32 %23, 0
br label %25
25: ; preds = %22, %15
%26 = phi i1 [ false, %15 ], [ %24, %22 ]
br i1 %26, label %27, label %30
27: ; preds = %25
%28 = load i32, i32* %6
%29 = add nsw i32 %28, -1
store i32 %29, i32* %6
br label %15
30: ; preds = %25
%31 = load i32, i32* %6
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 %32
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 46
br i1 %36, label %37, label %40
37: ; preds = %30
%38 = load i32, i32* %6
%39 = add nsw i32 %38, -1
store i32 %39, i32* %6
br label %40
40: ; preds = %37, %30
%41 = load i32, i32* %6
%42 = add nsw i32 %41, 2
store i32 %42, i32* %6
%43 = load i32, i32* %6
%44 = zext i32 %43 to i64
%45 = call i8* @llvm.stacksave()
store i8* %45, i8** %7
%46 = alloca i8, i64 %44
store i64 %44, i64* %8
%47 = load i32, i32* %6
%48 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%49 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %46, i32 %47, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %48)
%50 = load i8*, i8** %3
%51 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %50, i8* %46)
%52 = load i8*, i8** %7
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%f\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [6 x i8] c"%s%s\0A\00"
define void @print(i8* %0, double %1) {
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%5 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %4, i32 100, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), double %1)
%6 = call i32 @strlen(i8* %4)
%7 = sext i32 %6 to i64
br label %8
8: ; preds = %8, %2
%9 = phi i64 [ %10, %8 ], [ %7, %2 ]
%10 = add nsw i64 %9, -1
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %10
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 48
%14 = icmp sgt i64 %9, 1
%15 = select i1 %13, i1 %14, i1 false
br i1 %15, label %8, label %16
16: ; preds = %8
%17 = trunc i64 %9 to i32
%18 = trunc i64 %10 to i32
%19 = icmp eq i8 %12, 46
%20 = add nsw i32 %17, -2
%21 = select i1 %19, i32 %20, i32 %18
%22 = add nsw i32 %21, 2
%23 = zext i32 %22 to i64
%24 = call i8* @llvm.stacksave()
%25 = alloca i8, i64 %23
%26 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %25, i32 %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%27 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %0, i8* %25)
ret void
}