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

/* Variables and functions */
int /*<<< orphan*/ LOG_WARNING;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
scalar_t__ handle_line(char *);
char *strchr(char *, char);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, char const *, ...);
void read_crontab(const char *name) {
  FILE *file = fopen(name, "r");
  if (!file) {
    syslog(LOG_WARNING, "unable to read crontab `%s'", name);
    return;
  }
  char line[16384];
  unsigned lineno = 0;
  while (fgets(line, sizeof(line), file)) {
    lineno++;
    char *comment = strchr(line, '#');
    if (comment)
      *comment = 0;
    if (handle_line(line))
      syslog(LOG_WARNING, "syntax error in `%s', line %u", name, lineno);
  }
  fclose(file);
}


x86 assembly (clang, -O0):
<read_crontab>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4020,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe86(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11ae <read_crontab+0x4e>
mov    0x2e53(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe60(%rip),%rsi
mov    $0x0,%al
call   1070 <syslog@plt>
jmp    125b <read_crontab+0xfb>
movl   $0x0,-0x4014(%rbp)
lea    -0x4010(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x4000,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     1252 <read_crontab+0xf2>
mov    -0x4014(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4014(%rbp)
lea    -0x4010(%rbp),%rdi
mov    $0x23,%esi
call   1040 <strchr@plt>
mov    %rax,-0x4020(%rbp)
cmpq   $0x0,-0x4020(%rbp)
je     1216 <read_crontab+0xb6>
mov    -0x4020(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x4010(%rbp),%rdi
call   1050 <handle_line@plt>
cmp    $0x0,%rax
je     124d <read_crontab+0xed>
mov    0x2db5(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x4014(%rbp),%ecx
lea    0xdd8(%rip),%rsi
mov    $0x0,%al
call   1070 <syslog@plt>
jmp    11b8 <read_crontab+0x58>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x4020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_crontab>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x4008,%rsp
mov    %rdi,%r14
lea    0xe85(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1229 <read_crontab+0xc9>
mov    %rax,%r15
mov    %rsp,%rdi
mov    $0x4000,%esi
mov    %rax,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     120f <read_crontab+0xaf>
mov    $0x1,%ebp
mov    %rsp,%rbx
mov    0x2e38(%rip),%r13
lea    0xe67(%rip),%r12
jmp    11d8 <read_crontab+0x78>
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    $0x4000,%esi
mov    %r15,%rdx
call   1060 <fgets@plt>
add    $0x1,%ebp
test   %rax,%rax
je     120f <read_crontab+0xaf>
mov    %rbx,%rdi
mov    $0x23,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     11ed <read_crontab+0x8d>
movb   $0x0,(%rax)
mov    %rbx,%rdi
call   1050 <handle_line@plt>
test   %rax,%rax
je     11c0 <read_crontab+0x60>
mov    0x0(%r13),%edi
mov    %r12,%rsi
mov    %r14,%rdx
mov    %ebp,%ecx
xor    %eax,%eax
call   1070 <syslog@plt>
jmp    11c0 <read_crontab+0x60>
mov    %r15,%rdi
call   1030 <fclose@plt>
add    $0x4008,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2db8(%rip),%rax
mov    (%rax),%edi
lea    0xdc9(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
add    $0x4008,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <syslog@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@LOG_WARNING = global i32 0
@.str.1 = [28 x i8] c"unable to read crontab `%s'\00"
@.str.2 = [30 x i8] c"syntax error in `%s', line %u\00"
define void @read_crontab(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca [16384 x i8]
%5 = alloca i32
%6 = alloca i8*
store i8* %0, i8** %2
%7 = load i8*, i8** %2
%8 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %8, i32** %3
%9 = load i32*, i32** %3
%10 = icmp ne i32* %9, null
br i1 %10, label %15, label %11
11: ; preds = %1
%12 = load i32, i32* @LOG_WARNING
%13 = load i8*, i8** %2
%14 = call i32 (i32, i8*, i8*, ...) @syslog(i32 %12, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %13)
br label %43
15: ; preds = %1
store i32 0, i32* %5
br label %16
16: ; preds = %39, %15
%17 = getelementptr inbounds [16384 x i8], [16384 x i8]* %4, i64 0, i64 0
%18 = load i32*, i32** %3
%19 = call i64 @fgets(i8* %17, i32 16384, i32* %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %40
21: ; preds = %16
%22 = load i32, i32* %5
%23 = add i32 %22, 1
store i32 %23, i32* %5
%24 = getelementptr inbounds [16384 x i8], [16384 x i8]* %4, i64 0, i64 0
%25 = call i8* @strchr(i8* %24, i8 signext 35)
store i8* %25, i8** %6
%26 = load i8*, i8** %6
%27 = icmp ne i8* %26, null
br i1 %27, label %28, label %30
28: ; preds = %21
%29 = load i8*, i8** %6
store i8 0, i8* %29
br label %30
30: ; preds = %28, %21
%31 = getelementptr inbounds [16384 x i8], [16384 x i8]* %4, i64 0, i64 0
%32 = call i64 @handle_line(i8* %31)
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %39
34: ; preds = %30
%35 = load i32, i32* @LOG_WARNING
%36 = load i8*, i8** %2
%37 = load i32, i32* %5
%38 = call i32 (i32, i8*, i8*, ...) @syslog(i32 %35, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* %36, i32 %37)
br label %39
39: ; preds = %34, %30
br label %16
40: ; preds = %16
%41 = load i32*, i32** %3
%42 = call i32 @fclose(i32* %41)
br label %43
43: ; preds = %40, %11
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@LOG_WARNING = global i32 0
@.str.1 = [28 x i8] c"unable to read crontab `%s'\00"
@.str.2 = [30 x i8] c"syntax error in `%s', line %u\00"
define void @read_crontab(i8* %0) {
%2 = alloca [16384 x i8]
%3 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %8
5: ; preds = %1
%6 = load i32, i32* @LOG_WARNING
%7 = tail call i32 (i32, i8*, i8*, ...) @syslog(i32 %6, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %29
8: ; preds = %1
%9 = getelementptr inbounds [16384 x i8], [16384 x i8]* %2, i64 0, i64 0
%10 = call i64 @fgets(i8* %9, i32 16384, i32* %3)
%11 = icmp eq i64 %10, 0
br i1 %11, label %27, label %12
12: ; preds = %8, %24
%13 = phi i32 [ %14, %24 ], [ 0, %8 ]
%14 = add i32 %13, 1
%15 = call i8* @strchr(i8* %9, i8 signext 35)
%16 = icmp eq i8* %15, null
br i1 %16, label %18, label %17
17: ; preds = %12
store i8 0, i8* %15
br label %18
18: ; preds = %17, %12
%19 = call i64 @handle_line(i8* %9)
%20 = icmp eq i64 %19, 0
br i1 %20, label %24, label %21
21: ; preds = %18
%22 = load i32, i32* @LOG_WARNING
%23 = call i32 (i32, i8*, i8*, ...) @syslog(i32 %22, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* %0, i32 %14)
br label %24
24: ; preds = %21, %18
%25 = call i64 @fgets(i8* %9, i32 16384, i32* %3)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %12
27: ; preds = %24, %8
%28 = call i32 @fclose(i32* %3)
br label %29
29: ; preds = %27, %5
ret void
}