#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 */
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *scan_next_non_comment_line(char *line, int len, FILE *fp) {
  char *rtn = NULL;
  {
    char *buffer = (char *)malloc(sizeof(char) * len);
    int found = 0;
    while (fgets(buffer, len, fp) != NULL) {
      if (buffer[0] != '#')
        found = 1;
      break;
    }
    if (found) {
      strncpy(line, buffer, len);
      rtn = line;
    }
    free(buffer);
  }
  return rtn;
}


x86 assembly (clang, -O0):
<scan_next_non_comment_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movslq -0xc(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     11ab <scan_next_non_comment_line+0x6b>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x23,%eax
je     11a6 <scan_next_non_comment_line+0x66>
movl   $0x1,-0x2c(%rbp)
jmp    11ab <scan_next_non_comment_line+0x6b>
cmpl   $0x0,-0x2c(%rbp)
je     11cd <scan_next_non_comment_line+0x8d>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1040 <strncpy@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scan_next_non_comment_line>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %esi,%ebp
mov    %rdi,%r14
mov    %esi,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %ebp,%esi
mov    %r15,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     1170 <scan_next_non_comment_line+0x30>
cmpb   $0x23,(%rbx)
jne    1175 <scan_next_non_comment_line+0x35>
xor    %r14d,%r14d
jmp    1182 <scan_next_non_comment_line+0x42>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1040 <strncpy@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @scan_next_non_comment_line(i8* %0, i32 %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32* %2, i32** %6
store i8* null, i8** %7
%10 = load i32, i32* %5
%11 = sext i32 %10 to i64
%12 = mul i64 1, %11
%13 = trunc i64 %12 to i32
%14 = call i64 @malloc(i32 %13)
%15 = inttoptr i64 %14 to i8*
store i8* %15, i8** %8
store i32 0, i32* %9
br label %16
16: ; preds = %3
%17 = load i8*, i8** %8
%18 = load i32, i32* %5
%19 = load i32*, i32** %6
%20 = call i32* @fgets(i8* %17, i32 %18, i32* %19)
%21 = icmp ne i32* %20, null
br i1 %21, label %22, label %30
22: ; preds = %16
%23 = load i8*, i8** %8
%24 = getelementptr inbounds i8, i8* %23, i64 0
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %26, 35
br i1 %27, label %28, label %29
28: ; preds = %22
store i32 1, i32* %9
br label %29
29: ; preds = %28, %22
br label %30
30: ; preds = %29, %16
%31 = load i32, i32* %9
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %39
33: ; preds = %30
%34 = load i8*, i8** %4
%35 = load i8*, i8** %8
%36 = load i32, i32* %5
%37 = call i32 @strncpy(i8* %34, i8* %35, i32 %36)
%38 = load i8*, i8** %4
store i8* %38, i8** %7
br label %39
39: ; preds = %33, %30
%40 = load i8*, i8** %8
%41 = call i32 @free(i8* %40)
%42 = load i8*, i8** %7
ret i8* %42
}

LLVM IR (-O2):
define i8* @scan_next_non_comment_line(i8* %0, i32 %1, i32* nocapture %2) {
%4 = tail call i64 @malloc(i32 %1)
%5 = inttoptr i64 %4 to i8*
%6 = tail call i32* @fgets(i8* %5, i32 %1, i32* %2)
%7 = icmp eq i32* %6, null
br i1 %7, label %13, label %8
8: ; preds = %3
%9 = load i8, i8* %5
%10 = icmp eq i8 %9, 35
br i1 %10, label %13, label %11
11: ; preds = %8
%12 = tail call i32 @strncpy(i8* %0, i8* %5, i32 %1)
br label %13
13: ; preds = %3, %11, %8
%14 = phi i8* [ %0, %11 ], [ null, %8 ], [ null, %3 ]
%15 = tail call i32 @free(i8* %5)
ret i8* %14
}