#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 *, ...);
int exchange(int lower, int upper, int step) {
  int fahr, celsius;
  fahr = lower;
  printf("fahr\tcelius\n");
  while (fahr <= upper) {
    celsius = 5 * (fahr - 32) / 9;
    printf("%d\t%d\n", fahr, celsius);
    fahr = fahr + step;
  }
}


x86 assembly (clang, -O0):
<exchange>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     1177 <exchange+0x67>
mov    -0x14(%rbp),%eax
sub    $0x20,%eax
imul   $0x5,%eax,%eax
mov    $0x9,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    1135 <exchange+0x25>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<exchange>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %esi,%r12d
mov    %edi,%ebx
lea    0xecd(%rip),%rdi
call   1030 <puts@plt>
cmp    %r12d,%ebx
jg     118e <exchange+0x6e>
lea    (%rbx,%rbx,4),%ebp
add    $0xffffff60,%ebp
lea    (%r14,%r14,4),%r13d
lea    0xea8(%rip),%r15
nopl   0x0(%rax,%rax,1)
movslq %ebp,%rbp
imul   $0x38e38e39,%rbp,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x21,%rdx
add    %eax,%edx
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    %r14d,%ebx
add    %r13d,%ebp
cmp    %r12d,%ebx
jle    1160 <exchange+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"fahr\09celius\0A\00"
@.str.1 = [7 x i8] c"%d\09%d\0A\00"
define i32 @exchange(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%10 = load i32, i32* %5
store i32 %10, i32* %8
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %16, %3
%13 = load i32, i32* %8
%14 = load i32, i32* %6
%15 = icmp sle i32 %13, %14
br i1 %15, label %16, label %27
16: ; preds = %12
%17 = load i32, i32* %8
%18 = sub nsw i32 %17, 32
%19 = mul nsw i32 5, %18
%20 = sdiv i32 %19, 9
store i32 %20, i32* %9
%21 = load i32, i32* %8
%22 = load i32, i32* %9
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %21, i32 %22)
%24 = load i32, i32* %8
%25 = load i32, i32* %7
%26 = add nsw i32 %24, %25
store i32 %26, i32* %8
br label %12
27: ; preds = %12
%28 = load i32, i32* %4
ret i32 %28
}

LLVM IR (-O2):
@.str.1 = [7 x i8] c"%d\09%d\0A\00"
@str = [12 x i8] c"fahr\09celius\00"
define i32 @exchange(i32 %0, i32 %1, i32 %2) {
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
%5 = icmp sgt i32 %0, %1
br i1 %5, label %14, label %6
6: ; preds = %3, %6
%7 = phi i32 [ %12, %6 ], [ %0, %3 ]
%8 = mul i32 %7, 5
%9 = add i32 %8, -160
%10 = sdiv i32 %9, 9
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %7, i32 %10)
%12 = add nsw i32 %7, %2
%13 = icmp sgt i32 %12, %1
br i1 %13, label %14, label %6
14: ; preds = %6, %3
ret i32 undef
}