#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 */
char EOF;
double celsius_to_farenheit(double);
double celsius_to_kelvin(double);
double farenheit_to_celsius(double);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
char getc(int /*<<< orphan*/);
double kelvin_to_celsius(double);
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
double strtod(char *, char **);
int main(int argc, char *argv[]) {
  double input;
  int command_flags = 0;
  if (argc - command_flags < 3) {
    fprintf(stderr,
            "Incorrect number of command arguements: %d\nYou may have "
            "forgotten to include the temperature units in the command.\n",
            (argc - 1));
    return 1;
  }
  int units_from_args;
  if (argc - command_flags != 3) {
    char *p;
    char *last_arguement = argv[argc - 1];
    input = strtod(last_arguement, &p);
    units_from_args = 1;
  } else {
    units_from_args = 0;
    char stdin_temp[1024];
    int i = 0;
    char c;
    while ((c = getc(stdin)) != EOF) {
      stdin_temp[i] = c;
      i++;
      if (c == '\n') {
        break;
      }
    }
    i++;
    stdin_temp[i] = '\0';
    char stdin_temp_final[0];
    for (int j = 0; j < i; j++) {
      stdin_temp_final[j] = stdin_temp[j];
    }
    char *o;
    input = strtod(stdin_temp_final, &o);
    if (*o != '\n') {
      fprintf(stderr, "Invalid input temperature: %s", stdin_temp_final);
      return 1;
    }
  }
  char start_unit = *argv[argc - units_from_args - 2];
  char end_unit = *argv[argc - units_from_args - 1];
  char entered_flags[2] = {start_unit, end_unit};
  int valid_flags = 1;
  for (int i = 0; i < 2; i++) {
    switch (entered_flags[i]) {
    case 'c':
    case 'f':
    case 'k':
      break;
    default:
      fprintf(stderr, "Invalid temperature unit: %c\n", entered_flags[i]);
      valid_flags = 0;
    }
  }
  if (valid_flags == 0) {
    fprintf(stderr, "Incorrect number of temperature flags.\n");
    return 1;
  }
  double celsius_temp;
  switch (start_unit) {
  case 'c':
    celsius_temp = input;
    break;
  case 'f':
    celsius_temp = farenheit_to_celsius(input);
    break;
  case 'k':
    celsius_temp = kelvin_to_celsius(input);
    break;
  }
  double output;
  switch (end_unit) {
  case 'c':
    output = celsius_temp;
    break;
  case 'f':
    output = celsius_to_farenheit(celsius_temp);
    break;
  case 'k':
    output = celsius_to_kelvin(celsius_temp);
    break;
  }
  printf("%lf\n", output);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x480,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%eax
sub    -0x1c(%rbp),%eax
cmp    $0x3,%eax
jge    11d8 <main+0x58>
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%edx
sub    $0x1,%edx
lea    0xe3b(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    15af <main+0x42f>
mov    -0x8(%rbp),%eax
sub    -0x1c(%rbp),%eax
cmp    $0x3,%eax
je     121a <main+0x9a>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1030 <strtod@plt>
movsd  %xmm0,-0x18(%rbp)
movl   $0x1,-0x20(%rbp)
jmp    1355 <main+0x1d5>
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x434(%rbp)
mov    0x2db6(%rip),%rax
mov    (%rax),%edi
call   10a0 <getc@plt>
mov    %al,-0x435(%rbp)
movsbl %al,%eax
mov    0x2d97(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1291 <main+0x111>
mov    -0x435(%rbp),%cl
movslq -0x434(%rbp),%rax
mov    %cl,-0x430(%rbp,%rax,1)
mov    -0x434(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x434(%rbp)
movsbl -0x435(%rbp),%eax
cmp    $0xa,%eax
jne    128c <main+0x10c>
jmp    1291 <main+0x111>
jmp    122b <main+0xab>
mov    -0x434(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x434(%rbp)
movslq -0x434(%rbp),%rax
movb   $0x0,-0x430(%rbp,%rax,1)
movl   $0x0,-0x43c(%rbp)
mov    -0x43c(%rbp),%eax
cmp    -0x434(%rbp),%eax
jge    12fb <main+0x17b>
movslq -0x43c(%rbp),%rax
mov    -0x430(%rbp,%rax,1),%cl
movslq -0x43c(%rbp),%rax
mov    %cl,-0x436(%rbp,%rax,1)
mov    -0x43c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x43c(%rbp)
jmp    12b9 <main+0x139>
lea    -0x436(%rbp),%rdi
lea    -0x448(%rbp),%rsi
call   1030 <strtod@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x448(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
je     1350 <main+0x1d0>
mov    0x2ca3(%rip),%rax
mov    (%rax),%edi
lea    -0x436(%rbp),%rdx
lea    0xd37(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    15af <main+0x42f>
jmp    1355 <main+0x1d5>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    -0x20(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    (%rax),%al
mov    %al,-0x449(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    -0x20(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    (%rax),%al
mov    %al,-0x44a(%rbp)
mov    -0x449(%rbp),%al
mov    %al,-0x44c(%rbp)
mov    -0x44a(%rbp),%al
mov    %al,-0x44b(%rbp)
movl   $0x1,-0x450(%rbp)
movl   $0x0,-0x454(%rbp)
cmpl   $0x2,-0x454(%rbp)
jge    145f <main+0x2df>
movslq -0x454(%rbp),%rax
movsbl -0x44c(%rbp,%rax,1),%eax
ff
mov    %eax,-0x46c(%rbp)
sub    $0x63,%eax
je     1411 <main+0x291>
jmp    13e9 <main+0x269>
mov    -0x46c(%rbp),%eax
sub    $0x66,%eax
je     1411 <main+0x291>
jmp    13fd <main+0x27d>
mov    -0x46c(%rbp),%eax
sub    $0x6b,%eax
jne    1416 <main+0x296>
jmp    1411 <main+0x291>
jmp    1446 <main+0x2c6>
mov    0x2bb3(%rip),%rax
mov    (%rax),%edi
movslq -0x454(%rbp),%rax
movsbl -0x44c(%rbp,%rax,1),%edx
ff
lea    0xc5d(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x450(%rbp)
jmp    144b <main+0x2cb>
mov    -0x454(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x454(%rbp)
jmp    13b9 <main+0x239>
cmpl   $0x0,-0x450(%rbp)
jne    148f <main+0x30f>
mov    0x2b5d(%rip),%rax
mov    (%rax),%edi
lea    0xc34(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    15af <main+0x42f>
movsbl -0x449(%rbp),%eax
mov    %eax,-0x470(%rbp)
sub    $0x63,%eax
je     14d2 <main+0x352>
jmp    14aa <main+0x32a>
mov    -0x470(%rbp),%eax
sub    $0x66,%eax
je     14e4 <main+0x364>
jmp    14be <main+0x33e>
mov    -0x470(%rbp),%eax
sub    $0x6b,%eax
je     14fb <main+0x37b>
jmp    150d <main+0x38d>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x460(%rbp)
ff
jmp    150d <main+0x38d>
movsd  -0x18(%rbp),%xmm0
call   1060 <farenheit_to_celsius@plt>
movsd  %xmm0,-0x460(%rbp)
ff
jmp    150d <main+0x38d>
movsd  -0x18(%rbp),%xmm0
call   1090 <kelvin_to_celsius@plt>
movsd  %xmm0,-0x460(%rbp)
ff
movsbl -0x44a(%rbp),%eax
mov    %eax,-0x474(%rbp)
sub    $0x63,%eax
je     1550 <main+0x3d0>
jmp    1528 <main+0x3a8>
mov    -0x474(%rbp),%eax
sub    $0x66,%eax
je     1565 <main+0x3e5>
jmp    153c <main+0x3bc>
mov    -0x474(%rbp),%eax
sub    $0x6b,%eax
je     157f <main+0x3ff>
jmp    1594 <main+0x414>
movsd  -0x460(%rbp),%xmm0
ff
movsd  %xmm0,-0x468(%rbp)
ff
jmp    1594 <main+0x414>
movsd  -0x460(%rbp),%xmm0
ff
call   1080 <celsius_to_farenheit@plt>
movsd  %xmm0,-0x468(%rbp)
ff
jmp    1594 <main+0x414>
movsd  -0x460(%rbp),%xmm0
ff
call   1070 <celsius_to_kelvin@plt>
movsd  %xmm0,-0x468(%rbp)
ff
movsd  -0x468(%rbp),%xmm0
ff
lea    0xb35(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x480,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x420,%rsp
mov    %edi,%r12d
cmp    $0x2,%edi
jg     11c0 <main+0x40>
mov    0x2e31(%rip),%rax
mov    (%rax),%edi
add    $0xffffffff,%r12d
lea    0xe54(%rip),%rsi
mov    %r12d,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%eax
jmp    1353 <main+0x1d3>
mov    %rsi,%r14
cmp    $0x3,%r12d
jne    1254 <main+0xd4>
xor    %ebx,%ebx
mov    0x2e12(%rip),%r15
mov    0x2e03(%rip),%r13
nopl   (%rax)
mov    (%r15),%edi
call   10a0 <getc@plt>
cmp    0x0(%r13),%al
je     11fa <main+0x7a>
mov    %al,0x20(%rsp,%rbx,1)
add    $0x1,%rbx
cmp    $0xa,%al
jne    11e0 <main+0x60>
lea    0x1(%rbx),%eax
cltq
movb   $0x0,0x20(%rsp,%rax,1)
xor    %r13d,%r13d
test   %ebx,%ebx
cmovle %r13d,%ebx
mov    0x20(%rsp,%rbx,1),%al
mov    %al,0xf(%rsp)
lea    0xf(%rsp),%rdi
lea    0x18(%rsp),%rsi
call   1030 <strtod@plt>
mov    0x18(%rsp),%rax
cmpb   $0xa,(%rax)
je     126d <main+0xed>
mov    0x2d9b(%rip),%rax
mov    (%rax),%edi
lea    0xe36(%rip),%rsi
lea    0xf(%rsp),%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%eax
jmp    1353 <main+0x1d3>
lea    -0x1(%r12),%eax
mov    (%r14,%rax,8),%rdi
lea    0x20(%rsp),%rsi
call   1030 <strtod@plt>
mov    $0xffffffff,%r13d
lea    (%r12,%r13,1),%eax
add    $0xfffffffe,%eax
mov    (%r14,%rax,8),%rax
movsbl (%rax),%r15d
lea    -0x1(%r13,%r12,1),%eax
mov    (%r14,%rax,8),%rax
movsbl (%rax),%ebx
lea    -0x63(%r15),%eax
cmp    $0x8,%eax
ja     129f <main+0x11f>
mov    $0x109,%ecx
bt     %eax,%ecx
jae    129f <main+0x11f>
xor    %eax,%eax
jmp    12c7 <main+0x147>
mov    0x2d2a(%rip),%rax
mov    (%rax),%edi
lea    0xde3(%rip),%rsi
mov    %r15d,%edx
xor    %eax,%eax
movsd  %xmm0,0x10(%rsp)
call   1050 <fprintf@plt>
movsd  0x10(%rsp),%xmm0
mov    $0x1,%al
lea    -0x63(%rbx),%ecx
cmp    $0x8,%ecx
ja     12ff <main+0x17f>
mov    $0x109,%edx
bt     %ecx,%edx
jae    12ff <main+0x17f>
test   %al,%al
jne    1318 <main+0x198>
cmp    $0x6b,%r15d
je     1336 <main+0x1b6>
cmp    $0x66,%r15d
jne    12ee <main+0x16e>
call   1060 <farenheit_to_celsius@plt>
cmp    $0x6b,%ebx
je     1340 <main+0x1c0>
cmp    $0x66,%ebx
jne    1345 <main+0x1c5>
call   1080 <celsius_to_farenheit@plt>
jmp    1345 <main+0x1c5>
mov    0x2cca(%rip),%rax
mov    (%rax),%edi
lea    0xd83(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x2cb1(%rip),%rax
mov    (%rax),%edi
lea    0xd88(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%eax
jmp    1353 <main+0x1d3>
call   1090 <kelvin_to_celsius@plt>
cmp    $0x6b,%ebx
jne    12f3 <main+0x173>
call   1070 <celsius_to_kelvin@plt>
lea    0xd8c(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x420,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [116 x i8] c"Incorrect number of command arguements: %d\0AYou may have forgotten to include the temperature units in the command.\0A\00"
@stdin = global i32 0
@EOF = global i8 0
@.str.1 = [30 x i8] c"Invalid input temperature: %s\00"
@.str.2 = [30 x i8] c"Invalid temperature unit: %c\0A\00"
@.str.3 = [40 x i8] c"Incorrect number of temperature flags.\0A\00"
@.str.4 = [5 x i8] c"%lf\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca [1024 x i8]
%12 = alloca i32
%13 = alloca i8
%14 = alloca [0 x i8]
%15 = alloca i32
%16 = alloca i8*
%17 = alloca i8
%18 = alloca i8
%19 = alloca [2 x i8]
%20 = alloca i32
%21 = alloca i32
%22 = alloca double
%23 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
%24 = load i32, i32* %4
%25 = load i32, i32* %7
%26 = sub nsw i32 %24, %25
%27 = icmp slt i32 %26, 3
br i1 %27, label %28, label %33
28: ; preds = %2
%29 = load i32, i32* @stderr
%30 = load i32, i32* %4
%31 = sub nsw i32 %30, 1
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([116 x i8], [116 x i8]* @.str, i64 0, i64 0), i32 %31)
store i32 1, i32* %3
br label %176
33: ; preds = %2
%34 = load i32, i32* %4
%35 = load i32, i32* %7
%36 = sub nsw i32 %34, %35
%37 = icmp ne i32 %36, 3
br i1 %37, label %38, label %47
38: ; preds = %33
%39 = load i8**, i8*** %5
%40 = load i32, i32* %4
%41 = sub nsw i32 %40, 1
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8*, i8** %39, i64 %42
%44 = load i8*, i8** %43
store i8* %44, i8** %10
%45 = load i8*, i8** %10
%46 = call double @strtod(i8* %45, i8** %9)
store double %46, double* %6
store i32 1, i32* %8
br label %100
47: ; preds = %33
store i32 0, i32* %8
store i32 0, i32* %12
br label %48
48: ; preds = %66, %47
%49 = load i32, i32* @stdin
%50 = call signext i8 @getc(i32 %49)
store i8 %50, i8* %13
%51 = sext i8 %50 to i32
%52 = load i8, i8* @EOF
%53 = sext i8 %52 to i32
%54 = icmp ne i32 %51, %53
br i1 %54, label %55, label %67
55: ; preds = %48
%56 = load i8, i8* %13
%57 = load i32, i32* %12
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 %58
store i8 %56, i8* %59
%60 = load i32, i32* %12
%61 = add nsw i32 %60, 1
store i32 %61, i32* %12
%62 = load i8, i8* %13
%63 = sext i8 %62 to i32
%64 = icmp eq i32 %63, 10
br i1 %64, label %65, label %66
65: ; preds = %55
br label %67
66: ; preds = %55
br label %48
67: ; preds = %65, %48
%68 = load i32, i32* %12
%69 = add nsw i32 %68, 1
store i32 %69, i32* %12
%70 = load i32, i32* %12
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 %71
store i8 0, i8* %72
store i32 0, i32* %15
br label %73
73: ; preds = %85, %67
%74 = load i32, i32* %15
%75 = load i32, i32* %12
%76 = icmp slt i32 %74, %75
br i1 %76, label %77, label %88
77: ; preds = %73
%78 = load i32, i32* %15
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 %79
%81 = load i8, i8* %80
%82 = load i32, i32* %15
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds [0 x i8], [0 x i8]* %14, i64 0, i64 %83
store i8 %81, i8* %84
br label %85
85: ; preds = %77
%86 = load i32, i32* %15
%87 = add nsw i32 %86, 1
store i32 %87, i32* %15
br label %73
88: ; preds = %73
%89 = getelementptr inbounds [0 x i8], [0 x i8]* %14, i64 0, i64 0
%90 = call double @strtod(i8* %89, i8** %16)
store double %90, double* %6
%91 = load i8*, i8** %16
%92 = load i8, i8* %91
%93 = sext i8 %92 to i32
%94 = icmp ne i32 %93, 10
br i1 %94, label %95, label %99
95: ; preds = %88
%96 = load i32, i32* @stderr
%97 = getelementptr inbounds [0 x i8], [0 x i8]* %14, i64 0, i64 0
%98 = call i32 (i32, i8*, ...) @fprintf(i32 %96, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %97)
store i32 1, i32* %3
br label %176
99: ; preds = %88
br label %100
100: ; preds = %99, %38
%101 = load i8**, i8*** %5
%102 = load i32, i32* %4
%103 = load i32, i32* %8
%104 = sub nsw i32 %102, %103
%105 = sub nsw i32 %104, 2
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds i8*, i8** %101, i64 %106
%108 = load i8*, i8** %107
%109 = load i8, i8* %108
store i8 %109, i8* %17
%110 = load i8**, i8*** %5
%111 = load i32, i32* %4
%112 = load i32, i32* %8
%113 = sub nsw i32 %111, %112
%114 = sub nsw i32 %113, 1
%115 = sext i32 %114 to i64
%116 = getelementptr inbounds i8*, i8** %110, i64 %115
%117 = load i8*, i8** %116
%118 = load i8, i8* %117
store i8 %118, i8* %18
%119 = getelementptr inbounds [2 x i8], [2 x i8]* %19, i64 0, i64 0
%120 = load i8, i8* %17
store i8 %120, i8* %119
%121 = getelementptr inbounds i8, i8* %119, i64 1
%122 = load i8, i8* %18
store i8 %122, i8* %121
store i32 1, i32* %20
store i32 0, i32* %21
br label %123
123: ; preds = %142, %100
%124 = load i32, i32* %21
%125 = icmp slt i32 %124, 2
br i1 %125, label %126, label %145
126: ; preds = %123
%127 = load i32, i32* %21
%128 = sext i32 %127 to i64
%129 = getelementptr inbounds [2 x i8], [2 x i8]* %19, i64 0, i64 %128
%130 = load i8, i8* %129
%131 = sext i8 %130 to i32
switch i32 %131, label %133 [
i32 99, label %132
i32 102, label %132
i32 107, label %132
]
132: ; preds = %126, %126, %126
br label %141
133: ; preds = %126
%134 = load i32, i32* @stderr
%135 = load i32, i32* %21
%136 = sext i32 %135 to i64
%137 = getelementptr inbounds [2 x i8], [2 x i8]* %19, i64 0, i64 %136
%138 = load i8, i8* %137
%139 = sext i8 %138 to i32
%140 = call i32 (i32, i8*, ...) @fprintf(i32 %134, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i32 %139)
store i32 0, i32* %20
br label %141
141: ; preds = %133, %132
br label %142
142: ; preds = %141
%143 = load i32, i32* %21
%144 = add nsw i32 %143, 1
store i32 %144, i32* %21
br label %123
145: ; preds = %123
%146 = load i32, i32* %20
%147 = icmp eq i32 %146, 0
br i1 %147, label %148, label %151
148: ; preds = %145
%149 = load i32, i32* @stderr
%150 = call i32 (i32, i8*, ...) @fprintf(i32 %149, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %3
br label %176
151: ; preds = %145
%152 = load i8, i8* %17
%153 = sext i8 %152 to i32
switch i32 %153, label %162 [
i32 99, label %154
i32 102, label %156
i32 107, label %159
]
154: ; preds = %151
%155 = load double, double* %6
store double %155, double* %22
br label %162
156: ; preds = %151
%157 = load double, double* %6
%158 = call double @farenheit_to_celsius(double %157)
store double %158, double* %22
br label %162
159: ; preds = %151
%160 = load double, double* %6
%161 = call double @kelvin_to_celsius(double %160)
store double %161, double* %22
br label %162
162: ; preds = %151, %159, %156, %154
%163 = load i8, i8* %18
%164 = sext i8 %163 to i32
switch i32 %164, label %173 [
i32 99, label %165
i32 102, label %167
i32 107, label %170
]
165: ; preds = %162
%166 = load double, double* %22
store double %166, double* %23
br label %173
167: ; preds = %162
%168 = load double, double* %22
%169 = call double @celsius_to_farenheit(double %168)
store double %169, double* %23
br label %173
170: ; preds = %162
%171 = load double, double* %22
%172 = call double @celsius_to_kelvin(double %171)
store double %172, double* %23
br label %173
173: ; preds = %162, %170, %167, %165
%174 = load double, double* %23
%175 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), double %174)
store i32 0, i32* %3
br label %176
176: ; preds = %173, %148, %95, %28
%177 = load i32, i32* %3
ret i32 %177
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [116 x i8] c"Incorrect number of command arguements: %d\0AYou may have forgotten to include the temperature units in the command.\0A\00"
@stdin = global i32 0
@EOF = global i8 0
@.str.1 = [30 x i8] c"Invalid input temperature: %s\00"
@.str.2 = [30 x i8] c"Invalid temperature unit: %c\0A\00"
@.str.3 = [40 x i8] c"Incorrect number of temperature flags.\0A\00"
@.str.4 = [5 x i8] c"%lf\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [0 x i8]
%4 = alloca i8*
%5 = alloca [1024 x i8]
%6 = alloca i8*
%7 = icmp slt i32 %0, 3
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = add nsw i32 %0, -1
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([116 x i8], [116 x i8]* @.str, i64 0, i64 0), i32 %10)
br label %96
12: ; preds = %2
%13 = icmp eq i32 %0, 3
br i1 %13, label %21, label %14
14: ; preds = %12
%15 = bitcast i8** %4 to i8*
%16 = add nsw i32 %0, -1
%17 = zext i32 %16 to i64
%18 = getelementptr inbounds i8*, i8** %1, i64 %17
%19 = load i8*, i8** %18
%20 = call double @strtod(i8* %19, i8** %4)
br label %54
21: ; preds = %12
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
br label %23
23: ; preds = %29, %21
%24 = phi i64 [ %31, %29 ], [ 0, %21 ]
%25 = load i32, i32* @stdin
%26 = tail call signext i8 @getc(i32 %25)
%27 = load i8, i8* @EOF
%28 = icmp eq i8 %26, %27
br i1 %28, label %33, label %29
29: ; preds = %23
%30 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %24
store i8 %26, i8* %30
%31 = add nuw i64 %24, 1
%32 = icmp eq i8 %26, 10
br i1 %32, label %33, label %23
33: ; preds = %29, %23
%34 = phi i64 [ %31, %29 ], [ %24, %23 ]
%35 = trunc i64 %34 to i32
%36 = shl i64 %34, 32
%37 = add i64 %36, 4294967296
%38 = ashr exact i64 %37, 32
%39 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %38
store i8 0, i8* %39
%40 = getelementptr inbounds [0 x i8], [0 x i8]* %3, i64 0, i64 0
%41 = call i32 @llvm.smax.i32(i32 %35, i32 0)
%42 = zext i32 %41 to i64
%43 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %42
%44 = load i8, i8* %43
store i8 %44, i8* %40
%45 = bitcast i8** %6 to i8*
%46 = call double @strtod(i8* %40, i8** %6)
%47 = load i8*, i8** %6
%48 = load i8, i8* %47
%49 = icmp eq i8 %48, 10
br i1 %49, label %50, label %51
50: ; preds = %33
br label %54
51: ; preds = %33
%52 = load i32, i32* @stderr
%53 = call i32 (i32, i8*, ...) @fprintf(i32 %52, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %40)
br label %96
54: ; preds = %50, %14
%55 = phi i32 [ -1, %14 ], [ 0, %50 ]
%56 = phi double [ %20, %14 ], [ %46, %50 ]
%57 = add i32 %55, %0
%58 = add nsw i32 %57, -2
%59 = zext i32 %58 to i64
%60 = getelementptr inbounds i8*, i8** %1, i64 %59
%61 = load i8*, i8** %60
%62 = load i8, i8* %61
%63 = add nsw i32 %57, -1
%64 = zext i32 %63 to i64
%65 = getelementptr inbounds i8*, i8** %1, i64 %64
%66 = load i8*, i8** %65
%67 = load i8, i8* %66
%68 = sext i8 %62 to i32
switch i32 %68, label %69 [
i32 99, label %72
i32 102, label %72
i32 107, label %72
]
69: ; preds = %54
%70 = load i32, i32* @stderr
%71 = call i32 (i32, i8*, ...) @fprintf(i32 %70, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i32 %68)
br label %72
72: ; preds = %69, %54, %54, %54
%73 = phi i1 [ true, %69 ], [ false, %54 ], [ false, %54 ], [ false, %54 ]
%74 = sext i8 %67 to i32
switch i32 %74, label %75 [
i32 99, label %78
i32 102, label %78
i32 107, label %78
]
75: ; preds = %72
%76 = load i32, i32* @stderr
%77 = call i32 (i32, i8*, ...) @fprintf(i32 %76, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i32 %74)
br label %79
78: ; preds = %72, %72, %72
br i1 %73, label %79, label %82
79: ; preds = %75, %78
%80 = load i32, i32* @stderr
%81 = call i32 (i32, i8*, ...) @fprintf(i32 %80, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0))
br label %96
82: ; preds = %78
switch i32 %68, label %87 [
i32 107, label %85
i32 102, label %83
]
83: ; preds = %82
%84 = call double @farenheit_to_celsius(double %56)
br label %87
85: ; preds = %82
%86 = call double @kelvin_to_celsius(double %56)
br label %87
87: ; preds = %82, %85, %83
%88 = phi double [ %86, %85 ], [ %84, %83 ], [ %56, %82 ]
switch i32 %74, label %93 [
i32 107, label %91
i32 102, label %89
]
89: ; preds = %87
%90 = call double @celsius_to_farenheit(double %88)
br label %93
91: ; preds = %87
%92 = call double @celsius_to_kelvin(double %88)
br label %93
93: ; preds = %87, %91, %89
%94 = phi double [ %92, %91 ], [ %90, %89 ], [ %88, %87 ]
%95 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), double %94)
br label %96
96: ; preds = %79, %93, %51, %8
%97 = phi i32 [ 1, %8 ], [ 1, %51 ], [ 1, %79 ], [ 0, %93 ]
ret i32 %97
}