#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 */
typedef int /*<<< orphan*/ line;

/* Variables and functions */
scalar_t__ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ shutdown_archiver();
int /*<<< orphan*/ stdin;
scalar_t__ strcmp(char *, char *);
void *run_command_loop(void *context) {
  char line[80];
  while (fgets(line, sizeof(line), stdin)) {
    if (strcmp(line, "exit\n") == 0)
      break;
    printf("The only command is exit (or Ctrl-D)\n");
    printf("> ");
  }
  shutdown_archiver();
  return NULL;
}


x86 assembly (clang, -O0):
<run_command_loop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x60(%rbp),%rdi
mov    0x2e91(%rip),%rax
mov    (%rax),%edx
mov    $0x50,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     11a9 <run_command_loop+0x69>
lea    -0x60(%rbp),%rdi
lea    0xe88(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    118c <run_command_loop+0x4c>
jmp    11a9 <run_command_loop+0x69>
lea    0xe73(%rip),%rdi
call   1030 <printf@plt>
lea    0xe8d(%rip),%rdi
call   1030 <printf@plt>
jmp    114c <run_command_loop+0xc>
mov    $0x0,%al
call   1060 <shutdown_archiver@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run_command_loop>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x50,%rsp
mov    0x2e84(%rip),%r13
mov    0x0(%r13),%edx
mov    %rsp,%rdi
mov    $0x50,%esi
call   1050 <fgets@plt>
test   %rax,%rax
je     11d6 <run_command_loop+0x86>
lea    0xe7f(%rip),%r14
mov    %rsp,%rbx
lea    0xe7e(%rip),%r15
lea    0xe74(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11d6 <run_command_loop+0x86>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
call   1040 <printf@plt>
mov    0x0(%r13),%edx
mov    %rbx,%rdi
mov    $0x50,%esi
call   1050 <fgets@plt>
test   %rax,%rax
jne    11a0 <run_command_loop+0x50>
xor    %eax,%eax
call   1070 <shutdown_archiver@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [6 x i8] c"exit\0A\00"
@.str.1 = [38 x i8] c"The only command is exit (or Ctrl-D)\0A\00"
@.str.2 = [3 x i8] c"> \00"
define i8* @run_command_loop(i8* %0) {
%2 = alloca i8*
%3 = alloca [80 x i8]
store i8* %0, i8** %2
br label %4
4: ; preds = %14, %1
%5 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%6 = load i32, i32* @stdin
%7 = call i64 @fgets(i8* %5, i32 80, i32 %6)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %17
9: ; preds = %4
%10 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%11 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %9
br label %17
14: ; preds = %9
%15 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %4
17: ; preds = %13, %4
%18 = call i32 (...) @shutdown_archiver()
ret i8* null
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [6 x i8] c"exit\0A\00"
@.str.2 = [3 x i8] c"> \00"
@str = [37 x i8] c"The only command is exit (or Ctrl-D)\00"
define noalias i8* @run_command_loop(i8* nocapture readnone %0) {
%2 = alloca [80 x i8]
%3 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%4 = load i32, i32* @stdin
%5 = call i64 @fgets(i8* %3, i32 80, i32 %4)
%6 = icmp eq i64 %5, 0
br i1 %6, label %16, label %7
7: ; preds = %1, %10
%8 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %16, label %10
10: ; preds = %7
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
%12 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%13 = load i32, i32* @stdin
%14 = call i64 @fgets(i8* %3, i32 80, i32 %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %7
16: ; preds = %10, %7, %1
%17 = call i32 (...) @shutdown_archiver()
ret i8* null
}