#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 fahr2celsius(int);
int /*<<< orphan*/ printf(char *, ...);
int printFahrList(int start, int end, int step, int withHead) {
  if (start <= end && step < 0 || start >= end && step > 0 || step == 0) {
    printf("params error!\n");
    return 1;
  }
  if (withHead) {
    printf("fahr\tcelsius\n");
  }
  int i = start;
  while (start <= end ? i <= end : i >= end) {
    printf("%d\t%d\n", i, fahr2celsius(i));
    i += step;
  }
}


x86 assembly (clang, -O0):
<printFahrList>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     114a <printFahrList+0x2a>
cmpl   $0x0,-0x10(%rbp)
jl     116a <printFahrList+0x4a>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jl     1160 <printFahrList+0x40>
cmpl   $0x0,-0x10(%rbp)
jg     116a <printFahrList+0x4a>
cmpl   $0x0,-0x10(%rbp)
jne    1184 <printFahrList+0x64>
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1210 <printFahrList+0xf0>
cmpl   $0x0,-0x14(%rbp)
je     119c <printFahrList+0x7c>
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     11c4 <printFahrList+0xa4>
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
setle  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x1c(%rbp)
jmp    11d5 <printFahrList+0xb5>
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
setge  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    $0x0,%eax
je     1210 <printFahrList+0xf0>
mov    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%edi
call   1030 <fahr2celsius@plt>
mov    -0x20(%rbp),%esi
mov    %eax,%edx
lea    0xe22(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    11a2 <printFahrList+0x82>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printFahrList>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%r14d
mov    %esi,%ebp
mov    %edi,%r12d
cmp    %esi,%edi
jg     1157 <printFahrList+0x27>
test   %r14d,%r14d
jns    1157 <printFahrList+0x27>
lea    0xec4(%rip),%rdi
call   1040 <puts@plt>
jmp    11be <printFahrList+0x8e>
cmp    %ebp,%r12d
setge  %al
test   %r14d,%r14d
setg   %dl
je     1149 <printFahrList+0x19>
and    %dl,%al
jne    1149 <printFahrList+0x19>
test   %ecx,%ecx
je     1179 <printFahrList+0x49>
lea    0xe93(%rip),%rdi
call   1040 <puts@plt>
lea    0xe80(%rip),%r15
mov    %r12d,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebx,%edi
call   1030 <fahr2celsius@plt>
mov    %r15,%rdi
mov    %ebx,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
add    %r14d,%ebx
xor    %eax,%eax
xor    %ecx,%ecx
cmp    %ebp,%ebx
setle  %al
setge  %cl
cmp    %ebp,%r12d
cmovle %eax,%ecx
test   %cl,%cl
jne    1190 <printFahrList+0x60>
mov    $0x1,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"params error!\0A\00"
@.str.1 = [14 x i8] c"fahr\09celsius\0A\00"
@.str.2 = [7 x i8] c"%d\09%d\0A\00"
define i32 @printFahrList(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%11 = load i32, i32* %6
%12 = load i32, i32* %7
%13 = icmp sle i32 %11, %12
br i1 %13, label %14, label %17
14: ; preds = %4
%15 = load i32, i32* %8
%16 = icmp slt i32 %15, 0
br i1 %16, label %27, label %17
17: ; preds = %14, %4
%18 = load i32, i32* %6
%19 = load i32, i32* %7
%20 = icmp sge i32 %18, %19
br i1 %20, label %21, label %24
21: ; preds = %17
%22 = load i32, i32* %8
%23 = icmp sgt i32 %22, 0
br i1 %23, label %27, label %24
24: ; preds = %21, %17
%25 = load i32, i32* %8
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %24, %21, %14
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %5
br label %61
29: ; preds = %24
%30 = load i32, i32* %9
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %29
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %34
34: ; preds = %32, %29
%35 = load i32, i32* %6
store i32 %35, i32* %10
br label %36
36: ; preds = %53, %34
%37 = load i32, i32* %6
%38 = load i32, i32* %7
%39 = icmp sle i32 %37, %38
br i1 %39, label %40, label %45
40: ; preds = %36
%41 = load i32, i32* %10
%42 = load i32, i32* %7
%43 = icmp sle i32 %41, %42
%44 = zext i1 %43 to i32
br label %50
45: ; preds = %36
%46 = load i32, i32* %10
%47 = load i32, i32* %7
%48 = icmp sge i32 %46, %47
%49 = zext i1 %48 to i32
br label %50
50: ; preds = %45, %40
%51 = phi i32 [ %44, %40 ], [ %49, %45 ]
%52 = icmp ne i32 %51, 0
br i1 %52, label %53, label %61
53: ; preds = %50
%54 = load i32, i32* %10
%55 = load i32, i32* %10
%56 = call i32 @fahr2celsius(i32 %55)
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %54, i32 %56)
%58 = load i32, i32* %8
%59 = load i32, i32* %10
%60 = add nsw i32 %59, %58
store i32 %60, i32* %10
br label %36
61: ; preds = %27, %50
%62 = load i32, i32* %5
ret i32 %62
}

LLVM IR (-O2):
@.str.2 = [7 x i8] c"%d\09%d\0A\00"
@str = [13 x i8] c"fahr\09celsius\00"
@str.3 = [14 x i8] c"params error!\00"
define i32 @printFahrList(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = icmp sle i32 %0, %1
%6 = icmp slt i32 %2, 0
%7 = and i1 %5, %6
br i1 %7, label %14, label %8
8: ; preds = %4
%9 = icmp sge i32 %0, %1
%10 = icmp sgt i32 %2, 0
%11 = and i1 %9, %10
%12 = icmp eq i32 %2, 0
%13 = or i1 %12, %11
br i1 %13, label %14, label %16
14: ; preds = %8, %4
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.3, i64 0, i64 0))
br label %29
16: ; preds = %8
%17 = icmp eq i32 %3, 0
br i1 %17, label %20, label %18
18: ; preds = %16
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
br label %20
20: ; preds = %16, %18
br label %21
21: ; preds = %20, %21
%22 = phi i32 [ %25, %21 ], [ %0, %20 ]
%23 = tail call i32 @fahr2celsius(i32 %22)
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %22, i32 %23)
%25 = add nsw i32 %22, %2
%26 = icmp sle i32 %25, %1
%27 = icmp sge i32 %25, %1
%28 = select i1 %5, i1 %26, i1 %27
br i1 %28, label %21, label %29
29: ; preds = %21, %14
ret i32 1
}