#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 */
int /*<<< orphan*/ execcmd(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int getpid();
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  char *s, line[1024];
  fprintf(stdout, "sched started: %d\n", getpid());
  while (fgets(line, (sizeof(line) / sizeof(line[0])), stdin) != NULL) {
    execcmd(line);
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e68(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x424(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    -0x424(%rbp),%edi
mov    %eax,%edx
lea    0xe72(%rip),%rsi
call   1060 <fprintf@plt>
lea    -0x420(%rbp),%rdi
mov    0x2e47(%rip),%rax
mov    (%rax),%edx
mov    $0x400,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     11c8 <main+0x78>
lea    -0x420(%rbp),%rdi
call   1030 <execcmd@plt>
jmp    1193 <main+0x43>
xor    %edi,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x408,%rsp
mov    0x2e77(%rip),%rax
mov    (%rax),%ebx
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xe8f(%rip),%rsi
mov    %ebx,%edi
mov    %eax,%edx
call   1060 <fprintf@plt>
mov    0x2e67(%rip),%r14
mov    (%r14),%edx
mov    %rsp,%rdi
mov    $0x400,%esi
call   1050 <fgets@plt>
test   %rax,%rax
je     11bd <main+0x6d>
mov    %rsp,%rbx
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1030 <execcmd@plt>
mov    (%r14),%edx
mov    %rbx,%rdi
mov    $0x400,%esi
call   1050 <fgets@plt>
test   %rax,%rax
jne    11a0 <main+0x50>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [19 x i8] c"sched started: %d\0A\00"
@stdin = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca [1024 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* @stdout
%9 = call i32 (...) @getpid()
%10 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %9)
br label %11
11: ; preds = %16, %2
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%13 = load i32, i32* @stdin
%14 = call i32* @fgets(i8* %12, i32 1024, i32 %13)
%15 = icmp ne i32* %14, null
br i1 %15, label %16, label %19
16: ; preds = %11
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%18 = call i32 @execcmd(i8* %17)
br label %11
19: ; preds = %11
%20 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [19 x i8] c"sched started: %d\0A\00"
@stdin = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = load i32, i32* @stdout
%6 = tail call i32 (...) @getpid()
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = load i32, i32* @stdin
%9 = call i32* @fgets(i8* %4, i32 1024, i32 %8)
%10 = icmp eq i32* %9, null
br i1 %10, label %16, label %11
11: ; preds = %2, %11
%12 = call i32 @execcmd(i8* %4)
%13 = load i32, i32* @stdin
%14 = call i32* @fgets(i8* %4, i32 1024, i32 %13)
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %11
16: ; preds = %11, %2
%17 = call i32 @exit(i32 0)
unreachable
}