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

/* Variables and functions */
char *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *);
int strlen(char *);
int /*<<< orphan*/ *strstr(char *, char *);
int read_line(FILE *file, char *line) {
  char *s;
  int len, i;
  while ((s = fgets(line, (256), file)) != NULL) {
    if (line[0] == '\n')
      continue;
    if (line[0] != '#')
      break;
  }
  if (s == NULL)
    return (-2);
  len = strlen(s);
  if (strstr(line, "uxj") != NULL)
    return (3);
  if (strstr(line, "raw") != NULL)
    return (1);
  if (strstr(line, "detrend") != NULL)
    return (2);
  if (strstr(line, "ms") != NULL) {
    i = 2;
    while (line[i] != '=')
      i++;
    if (i == len)
      return (-1);
    while (i >= 0)
      line[i--] = ' ';
    printf("line=%s\n", line);
    return (4);
  }
  return (-1);
}


x86 assembly (clang, -O0):
<read_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x100,%esi
call   1050 <fgets@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     119f <read_line+0x5f>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    1185 <read_line+0x45>
jmp    1150 <read_line+0x10>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x23,%eax
je     119a <read_line+0x5a>
jmp    119f <read_line+0x5f>
jmp    1150 <read_line+0x10>
cmpq   $0x0,-0x20(%rbp)
jne    11b6 <read_line+0x76>
movl   $0xfffffffe,-0x4(%rbp)
jmp    12dd <read_line+0x19d>
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe33(%rip),%rsi
call   1060 <strstr@plt>
cmp    $0x0,%rax
je     11e8 <read_line+0xa8>
movl   $0x3,-0x4(%rbp)
jmp    12dd <read_line+0x19d>
mov    -0x18(%rbp),%rdi
lea    0xe11(%rip),%rsi
call   1060 <strstr@plt>
cmp    $0x0,%rax
je     120e <read_line+0xce>
movl   $0x1,-0x4(%rbp)
jmp    12dd <read_line+0x19d>
mov    -0x18(%rbp),%rdi
lea    0xdef(%rip),%rsi
call   1060 <strstr@plt>
cmp    $0x0,%rax
je     1234 <read_line+0xf4>
movl   $0x2,-0x4(%rbp)
jmp    12dd <read_line+0x19d>
mov    -0x18(%rbp),%rdi
lea    0xdd1(%rip),%rsi
call   1060 <strstr@plt>
cmp    $0x0,%rax
je     12d6 <read_line+0x196>
movl   $0x2,-0x28(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3d,%eax
je     1278 <read_line+0x138>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1255 <read_line+0x115>
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jne    1290 <read_line+0x150>
movl   $0xffffffff,-0x4(%rbp)
jmp    12dd <read_line+0x19d>
jmp    1295 <read_line+0x155>
cmpl   $0x0,-0x28(%rbp)
jl     12ba <read_line+0x17a>
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%ecx
mov    %ecx,%edx
add    $0xffffffff,%edx
mov    %edx,-0x28(%rbp)
movslq %ecx,%rcx
movb   $0x20,(%rax,%rcx,1)
jmp    1295 <read_line+0x155>
mov    -0x18(%rbp),%rsi
lea    0xd4e(%rip),%rdi
call   1040 <printf@plt>
movl   $0x4,-0x4(%rbp)
jmp    12dd <read_line+0x19d>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_line>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%rbp
mov    %rsi,%rdi
mov    $0x100,%esi
mov    %rbp,%rdx
call   1060 <fgets@plt>
mov    $0xfffffffe,%r15d
jmp    1190 <read_line+0x40>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %rbp,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     11fb <read_line+0xab>
movzbl (%rbx),%ecx
cmp    $0x23,%cl
je     1180 <read_line+0x30>
cmp    $0xa,%cl
je     1180 <read_line+0x30>
mov    %rax,%rdi
call   1030 <strlen@plt>
mov    %eax,%r14d
lea    0xe4c(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strstr@plt>
mov    $0x3,%r15d
test   %rax,%rax
jne    11fb <read_line+0xab>
lea    0xe36(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strstr@plt>
mov    $0x1,%r15d
test   %rax,%rax
jne    11fb <read_line+0xab>
lea    0xe20(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strstr@plt>
mov    $0x2,%r15d
test   %rax,%rax
je     1209 <read_line+0xb9>
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe00(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strstr@plt>
mov    $0xffffffff,%r15d
test   %rax,%rax
je     11fb <read_line+0xab>
mov    $0x1,%edx
nopl   0x0(%rax,%rax,1)
cmpb   $0x3d,0x1(%rbx,%rdx,1)
lea    0x1(%rdx),%rdx
jne    1230 <read_line+0xe0>
cmp    %edx,%r14d
je     11fb <read_line+0xab>
mov    %edx,%edi
xor    %eax,%eax
test   %edx,%edx
cmovs  %edx,%eax
sub    %eax,%edx
sub    %rdx,%rdi
add    %rbx,%rdi
add    $0x1,%rdx
mov    $0x20,%esi
call   1050 <memset@plt>
lea    0xdad(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    $0x4,%r15d
jmp    11fb <read_line+0xab>

LLVM IR (-O0):
@.str = [4 x i8] c"uxj\00"
@.str.1 = [4 x i8] c"raw\00"
@.str.2 = [8 x i8] c"detrend\00"
@.str.3 = [3 x i8] c"ms\00"
@.str.4 = [9 x i8] c"line=%s\0A\00"
define i32 @read_line(i32* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %4
store i8* %1, i8** %5
br label %9
9: ; preds = %28, %20, %2
%10 = load i8*, i8** %5
%11 = load i32*, i32** %4
%12 = call i8* @fgets(i8* %10, i32 256, i32* %11)
store i8* %12, i8** %6
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %29
14: ; preds = %9
%15 = load i8*, i8** %5
%16 = getelementptr inbounds i8, i8* %15, i64 0
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 10
br i1 %19, label %20, label %21
20: ; preds = %14
br label %9
21: ; preds = %14
%22 = load i8*, i8** %5
%23 = getelementptr inbounds i8, i8* %22, i64 0
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp ne i32 %25, 35
br i1 %26, label %27, label %28
27: ; preds = %21
br label %29
28: ; preds = %21
br label %9
29: ; preds = %27, %9
%30 = load i8*, i8** %6
%31 = icmp eq i8* %30, null
br i1 %31, label %32, label %33
32: ; preds = %29
store i32 -2, i32* %3
br label %85
33: ; preds = %29
%34 = load i8*, i8** %6
%35 = call i32 @strlen(i8* %34)
store i32 %35, i32* %7
%36 = load i8*, i8** %5
%37 = call i32* @strstr(i8* %36, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%38 = icmp ne i32* %37, null
br i1 %38, label %39, label %40
39: ; preds = %33
store i32 3, i32* %3
br label %85
40: ; preds = %33
%41 = load i8*, i8** %5
%42 = call i32* @strstr(i8* %41, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%43 = icmp ne i32* %42, null
br i1 %43, label %44, label %45
44: ; preds = %40
store i32 1, i32* %3
br label %85
45: ; preds = %40
%46 = load i8*, i8** %5
%47 = call i32* @strstr(i8* %46, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%48 = icmp ne i32* %47, null
br i1 %48, label %49, label %50
49: ; preds = %45
store i32 2, i32* %3
br label %85
50: ; preds = %45
%51 = load i8*, i8** %5
%52 = call i32* @strstr(i8* %51, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%53 = icmp ne i32* %52, null
br i1 %53, label %54, label %84
54: ; preds = %50
store i32 2, i32* %8
br label %55
55: ; preds = %63, %54
%56 = load i8*, i8** %5
%57 = load i32, i32* %8
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8, i8* %56, i64 %58
%60 = load i8, i8* %59
%61 = sext i8 %60 to i32
%62 = icmp ne i32 %61, 61
br i1 %62, label %63, label %66
63: ; preds = %55
%64 = load i32, i32* %8
%65 = add nsw i32 %64, 1
store i32 %65, i32* %8
br label %55
66: ; preds = %55
%67 = load i32, i32* %8
%68 = load i32, i32* %7
%69 = icmp eq i32 %67, %68
br i1 %69, label %70, label %71
70: ; preds = %66
store i32 -1, i32* %3
br label %85
71: ; preds = %66
br label %72
72: ; preds = %75, %71
%73 = load i32, i32* %8
%74 = icmp sge i32 %73, 0
br i1 %74, label %75, label %81
75: ; preds = %72
%76 = load i8*, i8** %5
%77 = load i32, i32* %8
%78 = add nsw i32 %77, -1
store i32 %78, i32* %8
%79 = sext i32 %77 to i64
%80 = getelementptr inbounds i8, i8* %76, i64 %79
store i8 32, i8* %80
br label %72
81: ; preds = %72
%82 = load i8*, i8** %5
%83 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* %82)
store i32 4, i32* %3
br label %85
84: ; preds = %50
store i32 -1, i32* %3
br label %85
85: ; preds = %84, %81, %70, %49, %44, %39, %32
%86 = load i32, i32* %3
ret i32 %86
}

LLVM IR (-O2):
@.str = [4 x i8] c"uxj\00"
@.str.1 = [4 x i8] c"raw\00"
@.str.2 = [8 x i8] c"detrend\00"
@.str.3 = [3 x i8] c"ms\00"
@.str.4 = [9 x i8] c"line=%s\0A\00"
define i32 @read_line(i32* nocapture %0, i8* %1) {
%3 = tail call i8* @fgets(i8* %1, i32 256, i32* %0)
%4 = icmp eq i8* %3, null
br i1 %4, label %42, label %5
5: ; preds = %2, %8
%6 = phi i8* [ %9, %8 ], [ %3, %2 ]
%7 = load i8, i8* %1
switch i8 %7, label %11 [
i8 10, label %8
i8 35, label %8
]
8: ; preds = %5, %5
%9 = tail call i8* @fgets(i8* %1, i32 256, i32* %0)
%10 = icmp eq i8* %9, null
br i1 %10, label %42, label %5
11: ; preds = %5
%12 = tail call i32 @strlen(i8* %6)
%13 = tail call i32* @strstr(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %42
15: ; preds = %11
%16 = tail call i32* @strstr(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %42
18: ; preds = %15
%19 = tail call i32* @strstr(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %42
21: ; preds = %18
%22 = tail call i32* @strstr(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%23 = icmp eq i32* %22, null
br i1 %23, label %42, label %24
24: ; preds = %21, %24
%25 = phi i64 [ %29, %24 ], [ 2, %21 ]
%26 = getelementptr inbounds i8, i8* %1, i64 %25
%27 = load i8, i8* %26
%28 = icmp eq i8 %27, 61
%29 = add nuw i64 %25, 1
br i1 %28, label %30, label %24
30: ; preds = %24
%31 = trunc i64 %25 to i32
%32 = icmp eq i32 %12, %31
br i1 %32, label %42, label %33
33: ; preds = %30
%34 = and i64 %25, 4294967295
%35 = call i32 @llvm.smin.i32(i32 %31, i32 0)
%36 = sub i32 %31, %35
%37 = zext i32 %36 to i64
%38 = sub nsw i64 %34, %37
%39 = getelementptr i8, i8* %1, i64 %38
%40 = add nuw nsw i64 %37, 1
%41 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* %1)
br label %42
42: ; preds = %8, %2, %21, %30, %18, %15, %11, %33
%43 = phi i32 [ 4, %33 ], [ 3, %11 ], [ 1, %15 ], [ 2, %18 ], [ -1, %30 ], [ -1, %21 ], [ -2, %2 ], [ -2, %8 ]
ret i32 %43
}