#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*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdin;
int strlen(char *);
void Problem18() {
  char string[1000];
  int i, ascii;
  printf("Problem 18: Given a string, the program will print out its keypad "
         "press equivalent.\n");
  printf("Enter a sentence: ");
  fgets(string, 1000, stdin);
  string[strlen(string) - 1] = '\0';
  printf("The output is: ");
  for (i = 0; i < strlen(string); i++) {
    if (string[i] == ' ') {
      printf("0");
      continue;
    }
    ascii = (int)string[i];
    if (ascii >= 97 && ascii <= 99) {
      ascii = ascii - 96;
      while (ascii != 0) {
        printf("2");
        ascii--;
      }
      continue;
    } else if (ascii >= 100 && ascii <= 102) {
      ascii = ascii - 99;
      while (ascii != 0) {
        printf("3");
        ascii--;
      }
      continue;
    } else if (ascii >= 103 && ascii <= 105) {
      ascii = ascii - 102;
      while (ascii != 0) {
        printf("4");
        ascii--;
      }
      continue;
    } else if (ascii >= 106 && ascii <= 108) {
      ascii = ascii - 105;
      while (ascii != 0) {
        printf("5");
        ascii--;
      }
      continue;
    } else if (ascii >= 109 && ascii <= 111) {
      ascii = ascii - 108;
      while (ascii != 0) {
        printf("6");
        ascii--;
      }
      continue;
    } else if (ascii >= 112 && ascii <= 115) {
      ascii = ascii - 111;
      while (ascii != 0) {
        printf("7");
        ascii--;
      }
      continue;
    } else if (ascii >= 116 && ascii <= 118) {
      ascii = ascii - 115;
      while (ascii != 0) {
        printf("8");
        ascii--;
      }
      continue;
    } else if (ascii >= 119 && ascii <= 122) {
      ascii = ascii - 118;
      while (ascii != 0) {
        printf("9");
        ascii--;
      }
      continue;
    }
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<Problem18>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
lea    0xebe(%rip),%rdi
call   1040 <printf@plt>
lea    0xf07(%rip),%rdi
call   1040 <printf@plt>
lea    -0x3f0(%rbp),%rdi
mov    0x2e87(%rip),%rax
mov    (%rax),%edx
mov    $0x3e8,%esi
call   1050 <fgets@plt>
lea    -0x3f0(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x3f0(%rbp,%rax,1)
lea    0xedb(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x3f4(%rbp)
mov    -0x3f4(%rbp),%eax
mov    %eax,-0x3fc(%rbp)
lea    -0x3f0(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x3fc(%rbp),%eax
cmp    %ecx,%eax
jge    1516 <Problem18+0x3e6>
movslq -0x3f4(%rbp),%rax
movsbl -0x3f0(%rbp,%rax,1),%eax
ff
cmp    $0x20,%eax
jne    11ed <Problem18+0xbd>
lea    0xe95(%rip),%rdi
call   1040 <printf@plt>
jmp    1502 <Problem18+0x3d2>
movslq -0x3f4(%rbp),%rax
movsbl -0x3f0(%rbp,%rax,1),%eax
ff
mov    %eax,-0x3f8(%rbp)
cmpl   $0x61,-0x3f8(%rbp)
jl     125d <Problem18+0x12d>
cmpl   $0x63,-0x3f8(%rbp)
jg     125d <Problem18+0x12d>
mov    -0x3f8(%rbp),%eax
sub    $0x60,%eax
mov    %eax,-0x3f8(%rbp)
cmpl   $0x0,-0x3f8(%rbp)
je     1258 <Problem18+0x128>
lea    0xe3b(%rip),%rdi
call   1040 <printf@plt>
mov    -0x3f8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x3f8(%rbp)
jmp    122b <Problem18+0xfb>
jmp    1502 <Problem18+0x3d2>
cmpl   $0x64,-0x3f8(%rbp)
jl     12b8 <Problem18+0x188>
cmpl   $0x66,-0x3f8(%rbp)
jg     12b8 <Problem18+0x188>
mov    -0x3f8(%rbp),%eax
sub    $0x63,%eax
mov    %eax,-0x3f8(%rbp)
cmpl   $0x0,-0x3f8(%rbp)
je     12b3 <Problem18+0x183>
lea    0xde2(%rip),%rdi
call   1040 <printf@plt>
mov    -0x3f8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x3f8(%rbp)
jmp    1286 <Problem18+0x156>
jmp    1502 <Problem18+0x3d2>
cmpl   $0x67,-0x3f8(%rbp)
jl     1313 <Problem18+0x1e3>
cmpl   $0x69,-0x3f8(%rbp)
jg     1313 <Problem18+0x1e3>
mov    -0x3f8(%rbp),%eax
sub    $0x66,%eax
mov    %eax,-0x3f8(%rbp)
cmpl   $0x0,-0x3f8(%rbp)
je     130e <Problem18+0x1de>
lea    0xd89(%rip),%rdi
call   1040 <printf@plt>
mov    -0x3f8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x3f8(%rbp)
jmp    12e1 <Problem18+0x1b1>
jmp    1502 <Problem18+0x3d2>
cmpl   $0x6a,-0x3f8(%rbp)
jl     136e <Problem18+0x23e>
cmpl   $0x6c,-0x3f8(%rbp)
jg     136e <Problem18+0x23e>
mov    -0x3f8(%rbp),%eax
sub    $0x69,%eax
mov    %eax,-0x3f8(%rbp)
cmpl   $0x0,-0x3f8(%rbp)
je     1369 <Problem18+0x239>
lea    0xd30(%rip),%rdi
call   1040 <printf@plt>
mov    -0x3f8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x3f8(%rbp)
jmp    133c <Problem18+0x20c>
jmp    1502 <Problem18+0x3d2>
cmpl   $0x6d,-0x3f8(%rbp)
jl     13c9 <Problem18+0x299>
cmpl   $0x6f,-0x3f8(%rbp)
jg     13c9 <Problem18+0x299>
mov    -0x3f8(%rbp),%eax
sub    $0x6c,%eax
mov    %eax,-0x3f8(%rbp)
cmpl   $0x0,-0x3f8(%rbp)
je     13c4 <Problem18+0x294>
lea    0xcd7(%rip),%rdi
call   1040 <printf@plt>
mov    -0x3f8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x3f8(%rbp)
jmp    1397 <Problem18+0x267>
jmp    1502 <Problem18+0x3d2>
cmpl   $0x70,-0x3f8(%rbp)
jl     1424 <Problem18+0x2f4>
cmpl   $0x73,-0x3f8(%rbp)
jg     1424 <Problem18+0x2f4>
mov    -0x3f8(%rbp),%eax
sub    $0x6f,%eax
mov    %eax,-0x3f8(%rbp)
cmpl   $0x0,-0x3f8(%rbp)
je     141f <Problem18+0x2ef>
lea    0xc7e(%rip),%rdi
call   1040 <printf@plt>
mov    -0x3f8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x3f8(%rbp)
jmp    13f2 <Problem18+0x2c2>
jmp    1502 <Problem18+0x3d2>
cmpl   $0x74,-0x3f8(%rbp)
jl     147f <Problem18+0x34f>
cmpl   $0x76,-0x3f8(%rbp)
jg     147f <Problem18+0x34f>
mov    -0x3f8(%rbp),%eax
sub    $0x73,%eax
mov    %eax,-0x3f8(%rbp)
cmpl   $0x0,-0x3f8(%rbp)
je     147a <Problem18+0x34a>
lea    0xc25(%rip),%rdi
call   1040 <printf@plt>
mov    -0x3f8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x3f8(%rbp)
jmp    144d <Problem18+0x31d>
jmp    1502 <Problem18+0x3d2>
cmpl   $0x77,-0x3f8(%rbp)
jl     14da <Problem18+0x3aa>
cmpl   $0x7a,-0x3f8(%rbp)
jg     14da <Problem18+0x3aa>
mov    -0x3f8(%rbp),%eax
sub    $0x76,%eax
mov    %eax,-0x3f8(%rbp)
cmpl   $0x0,-0x3f8(%rbp)
je     14d5 <Problem18+0x3a5>
lea    0xbcc(%rip),%rdi
call   1040 <printf@plt>
mov    -0x3f8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x3f8(%rbp)
jmp    14a8 <Problem18+0x378>
jmp    1502 <Problem18+0x3d2>
jmp    14df <Problem18+0x3af>
jmp    14e4 <Problem18+0x3b4>
jmp    14e9 <Problem18+0x3b9>
jmp    14ee <Problem18+0x3be>
jmp    14f3 <Problem18+0x3c3>
jmp    14f8 <Problem18+0x3c8>
jmp    14fd <Problem18+0x3cd>
jmp    1502 <Problem18+0x3d2>
mov    -0x3f4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3f4(%rbp)
jmp    119c <Problem18+0x6c>
lea    0xb36(%rip),%rdi
call   1040 <printf@plt>
add    $0x400,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Problem18>:
push   %r15
push   %r14
push   %rbx
sub    $0x3f0,%rsp
lea    0xec0(%rip),%rdi
call   1040 <puts@plt>
lea    0xe91(%rip),%rdi
call   1060 <printf@plt>
mov    0x2e6d(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x3e8,%esi
call   1070 <fgets@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
lea    0xe70(%rip),%rdi
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
test   %eax,%eax
jle    1364 <Problem18+0x214>
xor    %r15d,%r15d
mov    %rsp,%r14
jmp    11e1 <Problem18+0x91>
mov    $0x30,%edi
call   1030 <putchar@plt>
add    $0x1,%r15
mov    %r14,%rdi
call   1050 <strlen@plt>
cltq
cmp    %rax,%r15
jge    1364 <Problem18+0x214>
movsbl (%rsp,%r15,1),%ebx
cmp    $0x20,%ebx
je     11c0 <Problem18+0x70>
lea    -0x61(%rbx),%eax
cmp    $0x2,%al
ja     1220 <Problem18+0xd0>
add    $0xffffffa0,%ebx
je     11ca <Problem18+0x7a>
nopw   0x0(%rax,%rax,1)
mov    $0x32,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    1200 <Problem18+0xb0>
jmp    11ca <Problem18+0x7a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    -0x64(%rbx),%eax
cmp    $0x2,%al
ja     1241 <Problem18+0xf1>
add    $0xffffff9d,%ebx
je     11ca <Problem18+0x7a>
nopl   0x0(%rax)
mov    $0x33,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    1230 <Problem18+0xe0>
jmp    11ca <Problem18+0x7a>
lea    -0x67(%rbx),%eax
cmp    $0x2,%al
ja     1274 <Problem18+0x124>
add    $0xffffff9a,%ebx
je     11ca <Problem18+0x7a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x34,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    1260 <Problem18+0x110>
jmp    11ca <Problem18+0x7a>
lea    -0x6a(%rbx),%eax
cmp    $0x2,%al
ja     12a4 <Problem18+0x154>
add    $0xffffff97,%ebx
je     11ca <Problem18+0x7a>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x35,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    1290 <Problem18+0x140>
jmp    11ca <Problem18+0x7a>
lea    -0x6d(%rbx),%eax
cmp    $0x2,%al
ja     12d4 <Problem18+0x184>
add    $0xffffff94,%ebx
je     11ca <Problem18+0x7a>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x36,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    12c0 <Problem18+0x170>
jmp    11ca <Problem18+0x7a>
mov    %ebx,%eax
and    $0xfc,%al
cmp    $0x70,%al
jne    1304 <Problem18+0x1b4>
add    $0xffffff91,%ebx
je     11ca <Problem18+0x7a>
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0x37,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    12f0 <Problem18+0x1a0>
jmp    11ca <Problem18+0x7a>
lea    -0x74(%rbx),%eax
cmp    $0x2,%al
ja     1334 <Problem18+0x1e4>
add    $0xffffff8d,%ebx
je     11ca <Problem18+0x7a>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x38,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    1320 <Problem18+0x1d0>
jmp    11ca <Problem18+0x7a>
lea    -0x7b(%rbx),%eax
cmp    $0xfc,%al
jb     11ca <Problem18+0x7a>
add    $0xffffff8a,%ebx
je     11ca <Problem18+0x7a>
nopl   0x0(%rax,%rax,1)
mov    $0x39,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    1350 <Problem18+0x200>
jmp    11ca <Problem18+0x7a>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x3f0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [85 x i8] c"Problem 18: Given a string, the program will print out its keypad press equivalent.\0A\00"
@.str.1 = [19 x i8] c"Enter a sentence: \00"
@stdin = global i32 0
@.str.2 = [16 x i8] c"The output is: \00"
@.str.3 = [2 x i8] c"0\00"
@.str.4 = [2 x i8] c"2\00"
@.str.5 = [2 x i8] c"3\00"
@.str.6 = [2 x i8] c"4\00"
@.str.7 = [2 x i8] c"5\00"
@.str.8 = [2 x i8] c"6\00"
@.str.9 = [2 x i8] c"7\00"
@.str.10 = [2 x i8] c"8\00"
@.str.11 = [2 x i8] c"9\00"
@.str.12 = [2 x i8] c"\0A\00"
define void @Problem18() {
%1 = alloca [1000 x i8]
%2 = alloca i32
%3 = alloca i32
%4 = call i32 @printf(i8* getelementptr inbounds ([85 x i8], [85 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%6 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%7 = load i32, i32* @stdin
%8 = call i32 @fgets(i8* %6, i32 1000, i32 %7)
%9 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%10 = call i32 @strlen(i8* %9)
%11 = sub nsw i32 %10, 1
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %12
store i8 0, i8* %13
%14 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %2
br label %15
15: ; preds = %178, %0
%16 = load i32, i32* %2
%17 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%18 = call i32 @strlen(i8* %17)
%19 = icmp slt i32 %16, %18
br i1 %19, label %20, label %181
20: ; preds = %15
%21 = load i32, i32* %2
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 32
br i1 %26, label %27, label %29
27: ; preds = %20
%28 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %178
29: ; preds = %20
%30 = load i32, i32* %2
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %31
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
store i32 %34, i32* %3
%35 = load i32, i32* %3
%36 = icmp sge i32 %35, 97
br i1 %36, label %37, label %51
37: ; preds = %29
%38 = load i32, i32* %3
%39 = icmp sle i32 %38, 99
br i1 %39, label %40, label %51
40: ; preds = %37
%41 = load i32, i32* %3
%42 = sub nsw i32 %41, 96
store i32 %42, i32* %3
br label %43
43: ; preds = %46, %40
%44 = load i32, i32* %3
%45 = icmp ne i32 %44, 0
br i1 %45, label %46, label %50
46: ; preds = %43
%47 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%48 = load i32, i32* %3
%49 = add nsw i32 %48, -1
store i32 %49, i32* %3
br label %43
50: ; preds = %43
br label %178
51: ; preds = %37, %29
%52 = load i32, i32* %3
%53 = icmp sge i32 %52, 100
br i1 %53, label %54, label %68
54: ; preds = %51
%55 = load i32, i32* %3
%56 = icmp sle i32 %55, 102
br i1 %56, label %57, label %68
57: ; preds = %54
%58 = load i32, i32* %3
%59 = sub nsw i32 %58, 99
store i32 %59, i32* %3
br label %60
60: ; preds = %63, %57
%61 = load i32, i32* %3
%62 = icmp ne i32 %61, 0
br i1 %62, label %63, label %67
63: ; preds = %60
%64 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%65 = load i32, i32* %3
%66 = add nsw i32 %65, -1
store i32 %66, i32* %3
br label %60
67: ; preds = %60
br label %178
68: ; preds = %54, %51
%69 = load i32, i32* %3
%70 = icmp sge i32 %69, 103
br i1 %70, label %71, label %85
71: ; preds = %68
%72 = load i32, i32* %3
%73 = icmp sle i32 %72, 105
br i1 %73, label %74, label %85
74: ; preds = %71
%75 = load i32, i32* %3
%76 = sub nsw i32 %75, 102
store i32 %76, i32* %3
br label %77
77: ; preds = %80, %74
%78 = load i32, i32* %3
%79 = icmp ne i32 %78, 0
br i1 %79, label %80, label %84
80: ; preds = %77
%81 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%82 = load i32, i32* %3
%83 = add nsw i32 %82, -1
store i32 %83, i32* %3
br label %77
84: ; preds = %77
br label %178
85: ; preds = %71, %68
%86 = load i32, i32* %3
%87 = icmp sge i32 %86, 106
br i1 %87, label %88, label %102
88: ; preds = %85
%89 = load i32, i32* %3
%90 = icmp sle i32 %89, 108
br i1 %90, label %91, label %102
91: ; preds = %88
%92 = load i32, i32* %3
%93 = sub nsw i32 %92, 105
store i32 %93, i32* %3
br label %94
94: ; preds = %97, %91
%95 = load i32, i32* %3
%96 = icmp ne i32 %95, 0
br i1 %96, label %97, label %101
97: ; preds = %94
%98 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%99 = load i32, i32* %3
%100 = add nsw i32 %99, -1
store i32 %100, i32* %3
br label %94
101: ; preds = %94
br label %178
102: ; preds = %88, %85
%103 = load i32, i32* %3
%104 = icmp sge i32 %103, 109
br i1 %104, label %105, label %119
105: ; preds = %102
%106 = load i32, i32* %3
%107 = icmp sle i32 %106, 111
br i1 %107, label %108, label %119
108: ; preds = %105
%109 = load i32, i32* %3
%110 = sub nsw i32 %109, 108
store i32 %110, i32* %3
br label %111
111: ; preds = %114, %108
%112 = load i32, i32* %3
%113 = icmp ne i32 %112, 0
br i1 %113, label %114, label %118
114: ; preds = %111
%115 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%116 = load i32, i32* %3
%117 = add nsw i32 %116, -1
store i32 %117, i32* %3
br label %111
118: ; preds = %111
br label %178
119: ; preds = %105, %102
%120 = load i32, i32* %3
%121 = icmp sge i32 %120, 112
br i1 %121, label %122, label %136
122: ; preds = %119
%123 = load i32, i32* %3
%124 = icmp sle i32 %123, 115
br i1 %124, label %125, label %136
125: ; preds = %122
%126 = load i32, i32* %3
%127 = sub nsw i32 %126, 111
store i32 %127, i32* %3
br label %128
128: ; preds = %131, %125
%129 = load i32, i32* %3
%130 = icmp ne i32 %129, 0
br i1 %130, label %131, label %135
131: ; preds = %128
%132 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%133 = load i32, i32* %3
%134 = add nsw i32 %133, -1
store i32 %134, i32* %3
br label %128
135: ; preds = %128
br label %178
136: ; preds = %122, %119
%137 = load i32, i32* %3
%138 = icmp sge i32 %137, 116
br i1 %138, label %139, label %153
139: ; preds = %136
%140 = load i32, i32* %3
%141 = icmp sle i32 %140, 118
br i1 %141, label %142, label %153
142: ; preds = %139
%143 = load i32, i32* %3
%144 = sub nsw i32 %143, 115
store i32 %144, i32* %3
br label %145
145: ; preds = %148, %142
%146 = load i32, i32* %3
%147 = icmp ne i32 %146, 0
br i1 %147, label %148, label %152
148: ; preds = %145
%149 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%150 = load i32, i32* %3
%151 = add nsw i32 %150, -1
store i32 %151, i32* %3
br label %145
152: ; preds = %145
br label %178
153: ; preds = %139, %136
%154 = load i32, i32* %3
%155 = icmp sge i32 %154, 119
br i1 %155, label %156, label %170
156: ; preds = %153
%157 = load i32, i32* %3
%158 = icmp sle i32 %157, 122
br i1 %158, label %159, label %170
159: ; preds = %156
%160 = load i32, i32* %3
%161 = sub nsw i32 %160, 118
store i32 %161, i32* %3
br label %162
162: ; preds = %165, %159
%163 = load i32, i32* %3
%164 = icmp ne i32 %163, 0
br i1 %164, label %165, label %169
165: ; preds = %162
%166 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
%167 = load i32, i32* %3
%168 = add nsw i32 %167, -1
store i32 %168, i32* %3
br label %162
169: ; preds = %162
br label %178
170: ; preds = %156, %153
br label %171
171: ; preds = %170
br label %172
172: ; preds = %171
br label %173
173: ; preds = %172
br label %174
174: ; preds = %173
br label %175
175: ; preds = %174
br label %176
176: ; preds = %175
br label %177
177: ; preds = %176
br label %178
178: ; preds = %177, %169, %152, %135, %118, %101, %84, %67, %50, %27
%179 = load i32, i32* %2
%180 = add nsw i32 %179, 1
store i32 %180, i32* %2
br label %15
181: ; preds = %15
%182 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.1 = [19 x i8] c"Enter a sentence: \00"
@stdin = global i32 0
@.str.2 = [16 x i8] c"The output is: \00"
@str = [84 x i8] c"Problem 18: Given a string, the program will print out its keypad press equivalent.\00"
define void @Problem18() {
%1 = alloca [1000 x i8]
%2 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([84 x i8], [84 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%5 = load i32, i32* @stdin
%6 = call i32 @fgets(i8* %2, i32 1000, i32 %5)
%7 = call i32 @strlen(i8* %2)
%8 = add nsw i32 %7, -1
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %9
store i8 0, i8* %10
%11 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @strlen(i8* %2)
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %115
14: ; preds = %0, %110
%15 = phi i64 [ %111, %110 ], [ 0, %0 ]
%16 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %15
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp eq i8 %17, 32
br i1 %19, label %20, label %22
20: ; preds = %14
%21 = call i32 @putchar(i32 48)
br label %110
22: ; preds = %14
%23 = add i8 %17, -97
%24 = icmp ult i8 %23, 3
br i1 %24, label %25, label %33
25: ; preds = %22
%26 = add nsw i32 %18, -96
%27 = icmp eq i32 %26, 0
br i1 %27, label %110, label %28
28: ; preds = %25, %28
%29 = phi i32 [ %31, %28 ], [ %26, %25 ]
%30 = call i32 @putchar(i32 50)
%31 = add nsw i32 %29, -1
%32 = icmp eq i32 %31, 0
br i1 %32, label %110, label %28
33: ; preds = %22
%34 = add i8 %17, -100
%35 = icmp ult i8 %34, 3
br i1 %35, label %36, label %44
36: ; preds = %33
%37 = add nsw i32 %18, -99
%38 = icmp eq i32 %37, 0
br i1 %38, label %110, label %39
39: ; preds = %36, %39
%40 = phi i32 [ %42, %39 ], [ %37, %36 ]
%41 = call i32 @putchar(i32 51)
%42 = add nsw i32 %40, -1
%43 = icmp eq i32 %42, 0
br i1 %43, label %110, label %39
44: ; preds = %33
%45 = add i8 %17, -103
%46 = icmp ult i8 %45, 3
br i1 %46, label %47, label %55
47: ; preds = %44
%48 = add nsw i32 %18, -102
%49 = icmp eq i32 %48, 0
br i1 %49, label %110, label %50
50: ; preds = %47, %50
%51 = phi i32 [ %53, %50 ], [ %48, %47 ]
%52 = call i32 @putchar(i32 52)
%53 = add nsw i32 %51, -1
%54 = icmp eq i32 %53, 0
br i1 %54, label %110, label %50
55: ; preds = %44
%56 = add i8 %17, -106
%57 = icmp ult i8 %56, 3
br i1 %57, label %58, label %66
58: ; preds = %55
%59 = add nsw i32 %18, -105
%60 = icmp eq i32 %59, 0
br i1 %60, label %110, label %61
61: ; preds = %58, %61
%62 = phi i32 [ %64, %61 ], [ %59, %58 ]
%63 = call i32 @putchar(i32 53)
%64 = add nsw i32 %62, -1
%65 = icmp eq i32 %64, 0
br i1 %65, label %110, label %61
66: ; preds = %55
%67 = add i8 %17, -109
%68 = icmp ult i8 %67, 3
br i1 %68, label %69, label %77
69: ; preds = %66
%70 = add nsw i32 %18, -108
%71 = icmp eq i32 %70, 0
br i1 %71, label %110, label %72
72: ; preds = %69, %72
%73 = phi i32 [ %75, %72 ], [ %70, %69 ]
%74 = call i32 @putchar(i32 54)
%75 = add nsw i32 %73, -1
%76 = icmp eq i32 %75, 0
br i1 %76, label %110, label %72
77: ; preds = %66
%78 = and i8 %17, -4
%79 = icmp eq i8 %78, 112
br i1 %79, label %80, label %88
80: ; preds = %77
%81 = add nsw i32 %18, -111
%82 = icmp eq i32 %81, 0
br i1 %82, label %110, label %83
83: ; preds = %80, %83
%84 = phi i32 [ %86, %83 ], [ %81, %80 ]
%85 = call i32 @putchar(i32 55)
%86 = add nsw i32 %84, -1
%87 = icmp eq i32 %86, 0
br i1 %87, label %110, label %83
88: ; preds = %77
%89 = add i8 %17, -116
%90 = icmp ult i8 %89, 3
br i1 %90, label %91, label %99
91: ; preds = %88
%92 = add nsw i32 %18, -115
%93 = icmp eq i32 %92, 0
br i1 %93, label %110, label %94
94: ; preds = %91, %94
%95 = phi i32 [ %97, %94 ], [ %92, %91 ]
%96 = call i32 @putchar(i32 56)
%97 = add nsw i32 %95, -1
%98 = icmp eq i32 %97, 0
br i1 %98, label %110, label %94
99: ; preds = %88
%100 = add i8 %17, -123
%101 = icmp ult i8 %100, -4
%102 = add nsw i32 %18, -118
%103 = icmp eq i32 %102, 0
%104 = select i1 %101, i1 true, i1 %103
br i1 %104, label %110, label %105
105: ; preds = %99, %105
%106 = phi i32 [ %108, %105 ], [ %102, %99 ]
%107 = call i32 @putchar(i32 57)
%108 = add nsw i32 %106, -1
%109 = icmp eq i32 %108, 0
br i1 %109, label %110, label %105
110: ; preds = %105, %94, %83, %72, %61, %50, %39, %28, %91, %80, %69, %58, %47, %36, %25, %99, %20
%111 = add nuw nsw i64 %15, 1
%112 = call i32 @strlen(i8* %2)
%113 = sext i32 %112 to i64
%114 = icmp slt i64 %111, %113
br i1 %114, label %14, label %115
115: ; preds = %110, %0
%116 = call i32 @putchar(i32 10)
ret void
}