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

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
void print_speed(u_int i) {
  if (i < 1000)
    printf("%u bits/sec", i);
  else if (i < 1000000)
    printf("%u kb/sec", i / 1000);
  else
    printf("%u Mb/sec", i / 1000000);
}


x86 assembly (clang, -O0):
<print_speed>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x3e8,-0x4(%rbp)
jge    113c <print_speed+0x2c>
mov    -0x4(%rbp),%esi
lea    0xece(%rip),%rdi
call   1030 <printf@plt>
jmp    1185 <print_speed+0x75>
cmpl   $0xf4240,-0x4(%rbp)
jge    1167 <print_speed+0x57>
mov    -0x4(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xeaf(%rip),%rdi
call   1030 <printf@plt>
jmp    1180 <print_speed+0x70>
mov    -0x4(%rbp),%eax
mov    $0xf4240,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xe9b(%rip),%rdi
call   1030 <printf@plt>
jmp    1185 <print_speed+0x75>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_speed>:
mov    %edi,%esi
cmp    $0x3e7,%edi
jg     1126 <print_speed+0x16>
lea    0xedf(%rip),%rdi
jmp    1030 <printf@plt>
mov    %esi,%eax
cmp    $0xf423f,%esi
ja     1147 <print_speed+0x37>
imul   $0x10624dd3,%rax,%rsi
shr    $0x26,%rsi
lea    0xeca(%rip),%rdi
jmp    1030 <printf@plt>
imul   $0x431bde83,%rax,%rsi
shr    $0x32,%rsi
lea    0xebd(%rip),%rdi
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"%u bits/sec\00"
@.str.1 = [10 x i8] c"%u kb/sec\00"
@.str.2 = [10 x i8] c"%u Mb/sec\00"
define void @print_speed(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp slt i32 %3, 1000
br i1 %4, label %5, label %8
5: ; preds = %1
%6 = load i32, i32* %2
%7 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %6)
br label %20
8: ; preds = %1
%9 = load i32, i32* %2
%10 = icmp slt i32 %9, 1000000
br i1 %10, label %11, label %15
11: ; preds = %8
%12 = load i32, i32* %2
%13 = sdiv i32 %12, 1000
%14 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %13)
br label %19
15: ; preds = %8
%16 = load i32, i32* %2
%17 = sdiv i32 %16, 1000000
%18 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %17)
br label %19
19: ; preds = %15, %11
br label %20
20: ; preds = %19, %5
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"%u bits/sec\00"
@.str.1 = [10 x i8] c"%u kb/sec\00"
@.str.2 = [10 x i8] c"%u Mb/sec\00"
define void @print_speed(i32 %0) {
%2 = icmp slt i32 %0, 1000
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %0)
br label %13
5: ; preds = %1
%6 = icmp ult i32 %0, 1000000
br i1 %6, label %7, label %10
7: ; preds = %5
%8 = udiv i32 %0, 1000
%9 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %8)
br label %13
10: ; preds = %5
%11 = udiv i32 %0, 1000000
%12 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %11)
br label %13
13: ; preds = %7, %10, %3
ret void
}