#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*/ free(char *);
char *getRequest(char *, char *);
void *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *strstr(char *, char *);
int /*<<< orphan*/ system(char *);
int main(int argc, char **argv) {
  char *json = getRequest("api.ihackernews.com", "/page");
  if (json != NULL) {
  } else {
    printf("Failed to get articles!\r\n");
    return -1;
  }
  int headerLen = 0;
  while (*json != '{') {
    json++;
    headerLen++;
  }
  int len = strlen(json);
  char **articles = malloc(sizeof(char *) * 10);
  char **urls = malloc(sizeof(char *) * 10);
  int total = 0;
  int articleLen = 0;
  int urlLen = 0;
  int currArticle = 0;
  while (*json != '\0' && currArticle < 10) {
    if (strstr(json, "title") == json) {
      json += 8;
      total += 8;
      articleLen = strstr(json, "\"") - json;
      articles[currArticle] = malloc(sizeof(char) * (articleLen + 1));
      strncpy(articles[currArticle], json, articleLen);
      articles[currArticle][articleLen] = '\0';
      json += articleLen + 9;
      total += articleLen + 9;
      articleLen = 0;
      urlLen = strstr(json, "\"") - json;
      urls[currArticle] = malloc(sizeof(char) * (urlLen + 1));
      strncpy(urls[currArticle], json, urlLen);
      urls[currArticle][urlLen] = '\0';
      json += urlLen;
      total += urlLen;
      urlLen = 0;
      currArticle++;
    }
    json++;
    total++;
  }
  json -= total;
  json -= headerLen;
  free(json);
  len--;
  int x;
  for (x = 0; x < 10; x++) {
    printf("%d) %s\r\n", (x + 1), articles[x]);
  }
  int choice = 0;
  do {
    printf("Your choice? 0 to quit.\t");
    scanf("%d", &choice);
  } while (choice < 0 || choice > 10);
  if (choice == 0)
    return 0;
  choice--;
  int commandLen = 9 + strlen(urls[choice]);
  char *command = malloc(sizeof(char) * (commandLen + 1));
  strcpy(command, "xdg-open ");
  strcat(command, urls[choice]);
  command[commandLen] = '\0';
  system(command);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe33(%rip),%rdi
lea    0xe40(%rip),%rsi
call   10c0 <getRequest@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11ed <main+0x3d>
jmp    1207 <main+0x57>
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1569 <main+0x3b9>
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x7b,%eax
je     1238 <main+0x88>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    120e <main+0x5e>
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x20(%rbp)
mov    $0x50,%edi
call   1090 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    $0x50,%edi
call   1090 <malloc@plt>
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
movl   $0x0,-0x40(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x59(%rbp)
je     129b <main+0xeb>
cmpl   $0xa,-0x40(%rbp)
setl   %al
mov    %al,-0x59(%rbp)
mov    -0x59(%rbp),%al
test   $0x1,%al
jne    12ab <main+0xfb>
jmp    1415 <main+0x265>
mov    -0x18(%rbp),%rdi
lea    0xd7e(%rip),%rsi
call   10d0 <strstr@plt>
cmp    -0x18(%rbp),%rax
jne    13fb <main+0x24b>
mov    -0x18(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x18(%rbp)
mov    -0x34(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xd55(%rip),%rsi
call   10d0 <strstr@plt>
mov    -0x18(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,%rdx
mov    -0x28(%rbp),%rax
movslq -0x40(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x28(%rbp),%rax
movslq -0x40(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x38(%rbp),%edx
call   1040 <strncpy@plt>
mov    -0x28(%rbp),%rax
movslq -0x40(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x38(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x38(%rbp),%ecx
add    $0x9,%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x38(%rbp),%eax
add    $0x9,%eax
add    -0x34(%rbp),%eax
mov    %eax,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xcc6(%rip),%rsi
call   10d0 <strstr@plt>
mov    -0x18(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,%rdx
mov    -0x30(%rbp),%rax
movslq -0x40(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x30(%rbp),%rax
movslq -0x40(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x3c(%rbp),%edx
call   1040 <strncpy@plt>
mov    -0x30(%rbp),%rax
movslq -0x40(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x3c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x3c(%rbp),%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x3c(%rbp),%eax
add    -0x34(%rbp),%eax
mov    %eax,-0x34(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    127c <main+0xcc>
mov    -0x34(%rbp),%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rdx
xor    %ecx,%ecx
sub    %rdx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x1c(%rbp),%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rdx
xor    %ecx,%ecx
sub    %rdx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x44(%rbp)
cmpl   $0xa,-0x44(%rbp)
jge    1492 <main+0x2e2>
mov    -0x44(%rbp),%esi
add    $0x1,%esi
mov    -0x28(%rbp),%rax
movslq -0x44(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xbbf(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    145a <main+0x2aa>
movl   $0x0,-0x48(%rbp)
lea    0xba5(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xbb0(%rip),%rdi
lea    -0x48(%rbp),%rsi
call   10a0 <scanf@plt>
mov    $0x1,%al
cmpl   $0x0,-0x48(%rbp)
mov    %al,-0x5a(%rbp)
jl     14d0 <main+0x320>
cmpl   $0xa,-0x48(%rbp)
setg   %al
mov    %al,-0x5a(%rbp)
mov    -0x5a(%rbp),%al
test   $0x1,%al
jne    1499 <main+0x2e9>
cmpl   $0x0,-0x48(%rbp)
jne    14f1 <main+0x341>
movl   $0x0,-0x4(%rbp)
jmp    1569 <main+0x3b9>
mov    -0x48(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x48(%rbp)
mov    -0x30(%rbp),%rax
movslq -0x48(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1060 <strlen@plt>
add    $0x9,%eax
mov    %eax,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rdi
lea    0xb2e(%rip),%rsi
call   1050 <strcpy@plt>
mov    -0x58(%rbp),%rdi
mov    -0x30(%rbp),%rax
movslq -0x48(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   10b0 <strcat@plt>
mov    -0x58(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x58(%rbp),%rdi
call   1070 <system@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0xe1b(%rip),%rdi
lea    0xe28(%rip),%rsi
call   10f0 <getRequest@plt>
test   %rax,%rax
je     1202 <main+0x32>
mov    %rax,%rbx
cmpb   $0x7b,(%rax)
jne    1218 <main+0x48>
xor    %ebp,%ebp
jmp    1231 <main+0x61>
lea    0xe46(%rip),%rdi
call   1070 <puts@plt>
mov    $0xffffffff,%eax
jmp    14d4 <main+0x304>
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    %rbp,%rax
cmpb   $0x7b,0x1(%rbx,%rbp,1)
lea    0x1(%rbp),%rbp
jne    1220 <main+0x50>
add    %rbp,%rbx
mov    %rbx,%rdi
call   1080 <strlen@plt>
mov    $0x50,%edi
call   10c0 <malloc@plt>
mov    %rax,0x18(%rsp)
mov    $0x50,%edi
call   10c0 <malloc@plt>
mov    %rax,0x10(%rsp)
xor    %r12d,%r12d
cmpb   $0x0,(%rbx)
je     1369 <main+0x199>
mov    %rbp,0x20(%rsp)
lea    0xdab(%rip),%r14
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
call   1080 <strlen@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %rax,%rdx
call   1050 <strncmp@plt>
test   %eax,%eax
jne    1349 <main+0x179>
lea    0x8(%rbx),%r13
mov    %r13,%rdi
mov    $0x22,%esi
call   10a0 <strchr@plt>
mov    %rax,%rbp
sub    %r13,%rbp
lea    0x1(%rbp),%edi
call   10c0 <malloc@plt>
mov    %rax,%r14
movslq %r12d,%r12
mov    0x18(%rsp),%rax
mov    %r14,(%rax,%r12,8)
mov    %r14,%rdi
mov    %r13,%rsi
mov    %ebp,%edx
call   1040 <strncpy@plt>
movslq %ebp,%rax
movb   $0x0,(%r14,%rax,1)
add    %eax,%r15d
lea    (%rax,%rbx,1),%r13
add    $0x8,%r13
lea    (%rax,%rbx,1),%r14
add    $0x11,%r14
mov    %r14,%rdi
mov    $0x22,%esi
call   10a0 <strchr@plt>
mov    %rax,%rbp
sub    %r14,%rbp
lea    0x1(%rbp),%edi
call   10c0 <malloc@plt>
mov    %rax,%rbx
mov    0x10(%rsp),%rax
mov    %rbx,(%rax,%r12,8)
mov    %rbx,%rdi
mov    %r14,%rsi
lea    0xcf2(%rip),%r14
mov    %ebp,%edx
call   1040 <strncpy@plt>
movslq %ebp,%rax
movb   $0x0,(%rbx,%rax,1)
lea    (%rax,%r13,1),%rbx
add    $0x9,%rbx
add    %eax,%r15d
add    $0x11,%r15d
add    $0x1,%r12d
add    $0x1,%r15d
cmpb   $0x0,0x1(%rbx)
lea    0x1(%rbx),%rbx
je     1361 <main+0x191>
cmp    $0xa,%r12d
jl     1280 <main+0xb0>
movslq %r15d,%r12
mov    0x20(%rsp),%rbp
sub    %r12,%rbx
sub    %rbp,%rbx
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x18(%rsp),%rbp
mov    0x0(%rbp),%rdx
lea    0xc99(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   10b0 <printf@plt>
mov    0x8(%rbp),%rdx
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   10b0 <printf@plt>
mov    0x10(%rbp),%rdx
mov    %rbx,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   10b0 <printf@plt>
mov    0x18(%rbp),%rdx
mov    %rbx,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   10b0 <printf@plt>
mov    0x20(%rbp),%rdx
mov    %rbx,%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   10b0 <printf@plt>
mov    0x28(%rbp),%rdx
mov    %rbx,%rdi
mov    $0x6,%esi
xor    %eax,%eax
call   10b0 <printf@plt>
mov    0x30(%rbp),%rdx
mov    %rbx,%rdi
mov    $0x7,%esi
xor    %eax,%eax
call   10b0 <printf@plt>
mov    0x38(%rbp),%rdx
mov    %rbx,%rdi
mov    $0x8,%esi
xor    %eax,%eax
call   10b0 <printf@plt>
mov    0x40(%rbp),%rdx
mov    %rbx,%rdi
mov    $0x9,%esi
xor    %eax,%eax
call   10b0 <printf@plt>
mov    0x48(%rbp),%rdx
mov    %rbx,%rdi
mov    $0xa,%esi
xor    %eax,%eax
call   10b0 <printf@plt>
movl   $0x0,0xc(%rsp)
lea    0xbd9(%rip),%r15
lea    0xbeb(%rip),%r12
lea    0xc(%rsp),%rbx
nopl   0x0(%rax)
mov    %r15,%rdi
xor    %eax,%eax
call   10b0 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   10d0 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0xa,%eax
ja     1460 <main+0x290>
test   %eax,%eax
je     14d2 <main+0x302>
add    $0xffffffff,%eax
mov    %eax,0xc(%rsp)
mov    0x10(%rsp),%r14
mov    (%r14,%rax,8),%rdi
call   1080 <strlen@plt>
movslq %eax,%rbp
lea    0xa(%rbp),%edi
call   10c0 <malloc@plt>
mov    %rax,%rbx
lea    0xb99(%rip),%rsi
mov    %rax,%rdi
call   1060 <strcpy@plt>
movslq 0xc(%rsp),%rax
mov    (%r14,%rax,8),%rsi
mov    %rbx,%rdi
call   10e0 <strcat@plt>
movb   $0x0,0x9(%rbp,%rbx,1)
mov    %rbx,%rdi
call   1090 <system@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"api.ihackernews.com\00"
@.str.1 = [6 x i8] c"/page\00"
@.str.2 = [26 x i8] c"Failed to get articles!\0D\0A\00"
@.str.3 = [6 x i8] c"title\00"
@.str.4 = [2 x i8] c"\22\00"
@.str.5 = [9 x i8] c"%d) %s\0D\0A\00"
@.str.6 = [25 x i8] c"Your choice? 0 to quit.\09\00"
@.str.7 = [3 x i8] c"%d\00"
@.str.8 = [10 x i8] c"xdg-open \00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8**
%10 = alloca i8**
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%19 = call i8* @getRequest(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
store i8* %19, i8** %6
%20 = load i8*, i8** %6
%21 = icmp ne i8* %20, null
br i1 %21, label %22, label %23
22: ; preds = %2
br label %25
23: ; preds = %2
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %3
br label %229
25: ; preds = %22
store i32 0, i32* %7
br label %26
26: ; preds = %31, %25
%27 = load i8*, i8** %6
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp ne i32 %29, 123
br i1 %30, label %31, label %36
31: ; preds = %26
%32 = load i8*, i8** %6
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %6
%34 = load i32, i32* %7
%35 = add nsw i32 %34, 1
store i32 %35, i32* %7
br label %26
36: ; preds = %26
%37 = load i8*, i8** %6
%38 = call i32 @strlen(i8* %37)
store i32 %38, i32* %8
%39 = call i8* @malloc(i32 80)
%40 = bitcast i8* %39 to i8**
store i8** %40, i8*** %9
%41 = call i8* @malloc(i32 80)
%42 = bitcast i8* %41 to i8**
store i8** %42, i8*** %10
store i32 0, i32* %11
store i32 0, i32* %12
store i32 0, i32* %13
store i32 0, i32* %14
br label %43
43: ; preds = %147, %36
%44 = load i8*, i8** %6
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = icmp ne i32 %46, 0
br i1 %47, label %48, label %51
48: ; preds = %43
%49 = load i32, i32* %14
%50 = icmp slt i32 %49, 10
br label %51
51: ; preds = %48, %43
%52 = phi i1 [ false, %43 ], [ %50, %48 ]
br i1 %52, label %53, label %152
53: ; preds = %51
%54 = load i8*, i8** %6
%55 = call i8* @strstr(i8* %54, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%56 = load i8*, i8** %6
%57 = icmp eq i8* %55, %56
br i1 %57, label %58, label %147
58: ; preds = %53
%59 = load i8*, i8** %6
%60 = getelementptr inbounds i8, i8* %59, i64 8
store i8* %60, i8** %6
%61 = load i32, i32* %11
%62 = add nsw i32 %61, 8
store i32 %62, i32* %11
%63 = load i8*, i8** %6
%64 = call i8* @strstr(i8* %63, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%65 = load i8*, i8** %6
%66 = ptrtoint i8* %64 to i64
%67 = ptrtoint i8* %65 to i64
%68 = sub i64 %66, %67
%69 = trunc i64 %68 to i32
store i32 %69, i32* %12
%70 = load i32, i32* %12
%71 = add nsw i32 %70, 1
%72 = sext i32 %71 to i64
%73 = mul i64 1, %72
%74 = trunc i64 %73 to i32
%75 = call i8* @malloc(i32 %74)
%76 = load i8**, i8*** %9
%77 = load i32, i32* %14
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds i8*, i8** %76, i64 %78
store i8* %75, i8** %79
%80 = load i8**, i8*** %9
%81 = load i32, i32* %14
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds i8*, i8** %80, i64 %82
%84 = load i8*, i8** %83
%85 = load i8*, i8** %6
%86 = load i32, i32* %12
%87 = call i32 @strncpy(i8* %84, i8* %85, i32 %86)
%88 = load i8**, i8*** %9
%89 = load i32, i32* %14
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds i8*, i8** %88, i64 %90
%92 = load i8*, i8** %91
%93 = load i32, i32* %12
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds i8, i8* %92, i64 %94
store i8 0, i8* %95
%96 = load i32, i32* %12
%97 = add nsw i32 %96, 9
%98 = load i8*, i8** %6
%99 = sext i32 %97 to i64
%100 = getelementptr inbounds i8, i8* %98, i64 %99
store i8* %100, i8** %6
%101 = load i32, i32* %12
%102 = add nsw i32 %101, 9
%103 = load i32, i32* %11
%104 = add nsw i32 %103, %102
store i32 %104, i32* %11
store i32 0, i32* %12
%105 = load i8*, i8** %6
%106 = call i8* @strstr(i8* %105, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%107 = load i8*, i8** %6
%108 = ptrtoint i8* %106 to i64
%109 = ptrtoint i8* %107 to i64
%110 = sub i64 %108, %109
%111 = trunc i64 %110 to i32
store i32 %111, i32* %13
%112 = load i32, i32* %13
%113 = add nsw i32 %112, 1
%114 = sext i32 %113 to i64
%115 = mul i64 1, %114
%116 = trunc i64 %115 to i32
%117 = call i8* @malloc(i32 %116)
%118 = load i8**, i8*** %10
%119 = load i32, i32* %14
%120 = sext i32 %119 to i64
%121 = getelementptr inbounds i8*, i8** %118, i64 %120
store i8* %117, i8** %121
%122 = load i8**, i8*** %10
%123 = load i32, i32* %14
%124 = sext i32 %123 to i64
%125 = getelementptr inbounds i8*, i8** %122, i64 %124
%126 = load i8*, i8** %125
%127 = load i8*, i8** %6
%128 = load i32, i32* %13
%129 = call i32 @strncpy(i8* %126, i8* %127, i32 %128)
%130 = load i8**, i8*** %10
%131 = load i32, i32* %14
%132 = sext i32 %131 to i64
%133 = getelementptr inbounds i8*, i8** %130, i64 %132
%134 = load i8*, i8** %133
%135 = load i32, i32* %13
%136 = sext i32 %135 to i64
%137 = getelementptr inbounds i8, i8* %134, i64 %136
store i8 0, i8* %137
%138 = load i32, i32* %13
%139 = load i8*, i8** %6
%140 = sext i32 %138 to i64
%141 = getelementptr inbounds i8, i8* %139, i64 %140
store i8* %141, i8** %6
%142 = load i32, i32* %13
%143 = load i32, i32* %11
%144 = add nsw i32 %143, %142
store i32 %144, i32* %11
store i32 0, i32* %13
%145 = load i32, i32* %14
%146 = add nsw i32 %145, 1
store i32 %146, i32* %14
br label %147
147: ; preds = %58, %53
%148 = load i8*, i8** %6
%149 = getelementptr inbounds i8, i8* %148, i32 1
store i8* %149, i8** %6
%150 = load i32, i32* %11
%151 = add nsw i32 %150, 1
store i32 %151, i32* %11
br label %43
152: ; preds = %51
%153 = load i32, i32* %11
%154 = load i8*, i8** %6
%155 = sext i32 %153 to i64
%156 = sub i64 0, %155
%157 = getelementptr inbounds i8, i8* %154, i64 %156
store i8* %157, i8** %6
%158 = load i32, i32* %7
%159 = load i8*, i8** %6
%160 = sext i32 %158 to i64
%161 = sub i64 0, %160
%162 = getelementptr inbounds i8, i8* %159, i64 %161
store i8* %162, i8** %6
%163 = load i8*, i8** %6
%164 = call i32 @free(i8* %163)
%165 = load i32, i32* %8
%166 = add nsw i32 %165, -1
store i32 %166, i32* %8
store i32 0, i32* %15
br label %167
167: ; preds = %179, %152
%168 = load i32, i32* %15
%169 = icmp slt i32 %168, 10
br i1 %169, label %170, label %182
170: ; preds = %167
%171 = load i32, i32* %15
%172 = add nsw i32 %171, 1
%173 = load i8**, i8*** %9
%174 = load i32, i32* %15
%175 = sext i32 %174 to i64
%176 = getelementptr inbounds i8*, i8** %173, i64 %175
%177 = load i8*, i8** %176
%178 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 %172, i8* %177)
br label %179
179: ; preds = %170
%180 = load i32, i32* %15
%181 = add nsw i32 %180, 1
store i32 %181, i32* %15
br label %167
182: ; preds = %167
store i32 0, i32* %16
br label %183
183: ; preds = %192, %182
%184 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0))
%185 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %16)
br label %186
186: ; preds = %183
%187 = load i32, i32* %16
%188 = icmp slt i32 %187, 0
br i1 %188, label %192, label %189
189: ; preds = %186
%190 = load i32, i32* %16
%191 = icmp sgt i32 %190, 10
br label %192
192: ; preds = %189, %186
%193 = phi i1 [ true, %186 ], [ %191, %189 ]
br i1 %193, label %183, label %194
194: ; preds = %192
%195 = load i32, i32* %16
%196 = icmp eq i32 %195, 0
br i1 %196, label %197, label %198
197: ; preds = %194
store i32 0, i32* %3
br label %229
198: ; preds = %194
%199 = load i32, i32* %16
%200 = add nsw i32 %199, -1
store i32 %200, i32* %16
%201 = load i8**, i8*** %10
%202 = load i32, i32* %16
%203 = sext i32 %202 to i64
%204 = getelementptr inbounds i8*, i8** %201, i64 %203
%205 = load i8*, i8** %204
%206 = call i32 @strlen(i8* %205)
%207 = add nsw i32 9, %206
store i32 %207, i32* %17
%208 = load i32, i32* %17
%209 = add nsw i32 %208, 1
%210 = sext i32 %209 to i64
%211 = mul i64 1, %210
%212 = trunc i64 %211 to i32
%213 = call i8* @malloc(i32 %212)
store i8* %213, i8** %18
%214 = load i8*, i8** %18
%215 = call i32 @strcpy(i8* %214, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0))
%216 = load i8*, i8** %18
%217 = load i8**, i8*** %10
%218 = load i32, i32* %16
%219 = sext i32 %218 to i64
%220 = getelementptr inbounds i8*, i8** %217, i64 %219
%221 = load i8*, i8** %220
%222 = call i32 @strcat(i8* %216, i8* %221)
%223 = load i8*, i8** %18
%224 = load i32, i32* %17
%225 = sext i32 %224 to i64
%226 = getelementptr inbounds i8, i8* %223, i64 %225
store i8 0, i8* %226
%227 = load i8*, i8** %18
%228 = call i32 @system(i8* %227)
store i32 0, i32* %3
br label %229
229: ; preds = %198, %197, %23
%230 = load i32, i32* %3
ret i32 %230
}

LLVM IR (-O2):
@.str = [20 x i8] c"api.ihackernews.com\00"
@.str.1 = [6 x i8] c"/page\00"
@.str.3 = [6 x i8] c"title\00"
@.str.5 = [9 x i8] c"%d) %s\0D\0A\00"
@.str.6 = [25 x i8] c"Your choice? 0 to quit.\09\00"
@.str.7 = [3 x i8] c"%d\00"
@.str.8 = [10 x i8] c"xdg-open \00"
@str = [25 x i8] c"Failed to get articles!\0D\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = tail call i8* @getRequest(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i8* %4, null
br i1 %5, label %9, label %6
6: ; preds = %2
%7 = load i8, i8* %4
%8 = icmp eq i8 %7, 123
br i1 %8, label %20, label %11
9: ; preds = %2
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
br label %148
11: ; preds = %6, %11
%12 = phi i8* [ %14, %11 ], [ %4, %6 ]
%13 = phi i32 [ %15, %11 ], [ 0, %6 ]
%14 = getelementptr inbounds i8, i8* %12, i64 1
%15 = add nuw nsw i32 %13, 1
%16 = load i8, i8* %14
%17 = icmp eq i8 %16, 123
br i1 %17, label %18, label %11
18: ; preds = %11
%19 = zext i32 %15 to i64
br label %20
20: ; preds = %18, %6
%21 = phi i64 [ 0, %6 ], [ %19, %18 ]
%22 = phi i8* [ %4, %6 ], [ %14, %18 ]
%23 = tail call i32 @strlen(i8* %22)
%24 = tail call dereferenceable_or_null(80) i8* @malloc(i32 80)
%25 = bitcast i8* %24 to i8**
%26 = tail call dereferenceable_or_null(80) i8* @malloc(i32 80)
%27 = bitcast i8* %26 to i8**
%28 = load i8, i8* %22
%29 = icmp eq i8 %28, 0
br i1 %29, label %84, label %30
30: ; preds = %20, %72
%31 = phi i8* [ %76, %72 ], [ %22, %20 ]
%32 = phi i32 [ %74, %72 ], [ 0, %20 ]
%33 = phi i32 [ %77, %72 ], [ 0, %20 ]
%34 = tail call i64 bitcast (i32 (i8*)* @strlen to i64 (i8*)*)(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%35 = tail call i32 @strncmp(i8* %31, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i64 %34)
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %72
37: ; preds = %30
%38 = getelementptr inbounds i8, i8* %31, i64 8
%39 = add nsw i32 %33, 8
%40 = tail call i8* @strchr(i8* %38, i32 34)
%41 = ptrtoint i8* %40 to i64
%42 = ptrtoint i8* %38 to i64
%43 = sub i64 %41, %42
%44 = trunc i64 %43 to i32
%45 = add nsw i32 %44, 1
%46 = tail call i8* @malloc(i32 %45)
%47 = sext i32 %32 to i64
%48 = getelementptr inbounds i8*, i8** %25, i64 %47
store i8* %46, i8** %48
%49 = tail call i32 @strncpy(i8* %46, i8* %38, i32 %44)
%50 = shl i64 %43, 32
%51 = ashr exact i64 %50, 32
%52 = getelementptr inbounds i8, i8* %46, i64 %51
store i8 0, i8* %52
%53 = add nsw i32 %44, 9
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i8, i8* %38, i64 %54
%56 = add nsw i32 %39, %53
%57 = tail call i8* @strchr(i8* %55, i32 34)
%58 = ptrtoint i8* %57 to i64
%59 = ptrtoint i8* %55 to i64
%60 = sub i64 %58, %59
%61 = trunc i64 %60 to i32
%62 = add nsw i32 %61, 1
%63 = tail call i8* @malloc(i32 %62)
%64 = getelementptr inbounds i8*, i8** %27, i64 %47
store i8* %63, i8** %64
%65 = tail call i32 @strncpy(i8* %63, i8* %55, i32 %61)
%66 = shl i64 %60, 32
%67 = ashr exact i64 %66, 32
%68 = getelementptr inbounds i8, i8* %63, i64 %67
store i8 0, i8* %68
%69 = getelementptr inbounds i8, i8* %55, i64 %67
%70 = add nsw i32 %56, %61
%71 = add nsw i32 %32, 1
br label %72
72: ; preds = %37, %30
%73 = phi i32 [ %70, %37 ], [ %33, %30 ]
%74 = phi i32 [ %71, %37 ], [ %32, %30 ]
%75 = phi i8* [ %69, %37 ], [ %31, %30 ]
%76 = getelementptr inbounds i8, i8* %75, i64 1
%77 = add nsw i32 %73, 1
%78 = load i8, i8* %76
%79 = icmp ne i8 %78, 0
%80 = icmp slt i32 %74, 10
%81 = select i1 %79, i1 %80, i1 false
br i1 %81, label %30, label %82
82: ; preds = %72
%83 = sext i32 %77 to i64
br label %84
84: ; preds = %82, %20
%85 = phi i64 [ 0, %20 ], [ %83, %82 ]
%86 = phi i8* [ %22, %20 ], [ %76, %82 ]
%87 = sub nsw i64 0, %85
%88 = getelementptr inbounds i8, i8* %86, i64 %87
%89 = sub nsw i64 0, %21
%90 = getelementptr inbounds i8, i8* %88, i64 %89
%91 = tail call i32 @free(i8* %90)
%92 = load i8*, i8** %25
%93 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 1, i8* %92)
%94 = getelementptr inbounds i8*, i8** %25, i64 1
%95 = load i8*, i8** %94
%96 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 2, i8* %95)
%97 = getelementptr inbounds i8*, i8** %25, i64 2
%98 = load i8*, i8** %97
%99 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 3, i8* %98)
%100 = getelementptr inbounds i8*, i8** %25, i64 3
%101 = load i8*, i8** %100
%102 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 4, i8* %101)
%103 = getelementptr inbounds i8*, i8** %25, i64 4
%104 = load i8*, i8** %103
%105 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 5, i8* %104)
%106 = getelementptr inbounds i8*, i8** %25, i64 5
%107 = load i8*, i8** %106
%108 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 6, i8* %107)
%109 = getelementptr inbounds i8*, i8** %25, i64 6
%110 = load i8*, i8** %109
%111 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 7, i8* %110)
%112 = getelementptr inbounds i8*, i8** %25, i64 7
%113 = load i8*, i8** %112
%114 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 8, i8* %113)
%115 = getelementptr inbounds i8*, i8** %25, i64 8
%116 = load i8*, i8** %115
%117 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 9, i8* %116)
%118 = getelementptr inbounds i8*, i8** %25, i64 9
%119 = load i8*, i8** %118
%120 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 10, i8* %119)
%121 = bitcast i32* %3 to i8*
store i32 0, i32* %3
br label %122
122: ; preds = %122, %84
%123 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0))
%124 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %3)
%125 = load i32, i32* %3
%126 = icmp ugt i32 %125, 10
br i1 %126, label %122, label %127
127: ; preds = %122
%128 = icmp eq i32 %125, 0
br i1 %128, label %147, label %129
129: ; preds = %127
%130 = add nsw i32 %125, -1
store i32 %130, i32* %3
%131 = zext i32 %130 to i64
%132 = getelementptr inbounds i8*, i8** %27, i64 %131
%133 = load i8*, i8** %132
%134 = call i32 @strlen(i8* %133)
%135 = add nsw i32 %134, 9
%136 = add nsw i32 %134, 10
%137 = call i8* @malloc(i32 %136)
%138 = call i32 @strcpy(i8* %137, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0))
%139 = load i32, i32* %3
%140 = sext i32 %139 to i64
%141 = getelementptr inbounds i8*, i8** %27, i64 %140
%142 = load i8*, i8** %141
%143 = call i32 @strcat(i8* %137, i8* %142)
%144 = sext i32 %135 to i64
%145 = getelementptr inbounds i8, i8* %137, i64 %144
store i8 0, i8* %145
%146 = call i32 @system(i8* %137)
br label %147
147: ; preds = %127, %129
br label %148
148: ; preds = %147, %9
%149 = phi i32 [ 0, %147 ], [ -1, %9 ]
ret i32 %149
}