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

/* Variables and functions */
int /*<<< orphan*/ assert(int /*<<< orphan*/);
char *find_section_start(char *s, int n) {
  int i = 0;
  assert(n >= 0 && "Invalid section number");
  if (n == 0)
    return s;
  while (i < n && (*s) != (char)0) {
    if (s[0] == '%' && s[1] == '%' && s[2] == '\n') {
      i++;
    }
    s++;
  }
  if (*s != (char)0)
    return s + 2;
  return s;
}


x86 assembly (clang, -O0):
<find_section_start>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x14(%rbp)
mov    %al,-0x19(%rbp)
jl     113f <find_section_start+0x2f>
mov    $0x1,%al
mov    %al,-0x19(%rbp)
jmp    113f <find_section_start+0x2f>
mov    -0x19(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x0,-0x14(%rbp)
jne    1163 <find_section_start+0x53>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    120e <find_section_start+0xfe>
jmp    1168 <find_section_start+0x58>
mov    -0x18(%rbp),%ecx
xor    %eax,%eax
cmp    -0x14(%rbp),%ecx
mov    %al,-0x1a(%rbp)
jge    1189 <find_section_start+0x79>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x1a(%rbp)
mov    -0x1a(%rbp),%al
test   $0x1,%al
jne    1199 <find_section_start+0x89>
jmp    11e5 <find_section_start+0xd5>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x25,%eax
jne    11d4 <find_section_start+0xc4>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x25,%eax
jne    11d4 <find_section_start+0xc4>
mov    -0x10(%rbp),%rax
movsbl 0x2(%rax),%eax
cmp    $0xa,%eax
jne    11d4 <find_section_start+0xc4>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1168 <find_section_start+0x58>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1206 <find_section_start+0xf6>
mov    -0x10(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x8(%rbp)
jmp    120e <find_section_start+0xfe>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_section_start>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
mov    %esi,%edi
not    %edi
shr    $0x1f,%edi
call   1030 <assert@plt>
test   %ebp,%ebp
je     1163 <find_section_start+0x53>
jle    1157 <find_section_start+0x47>
xor    %eax,%eax
jmp    113c <find_section_start+0x2c>
xchg   %ax,%ax
test   %cl,%cl
je     1157 <find_section_start+0x47>
add    $0x1,%rbx
cmp    %ebp,%eax
jge    1157 <find_section_start+0x47>
movzbl (%rbx),%ecx
cmp    $0x25,%cl
jne    1130 <find_section_start+0x20>
cmpb   $0x25,0x1(%rbx)
jne    1134 <find_section_start+0x24>
xor    %ecx,%ecx
cmpb   $0xa,0x2(%rbx)
sete   %cl
add    %ecx,%eax
jmp    1134 <find_section_start+0x24>
xor    %eax,%eax
cmpb   $0x0,(%rbx)
setne  %al
lea    (%rbx,%rax,2),%rbx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Invalid section number\00"
define i8* @find_section_start(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 0, i32* %6
%7 = load i32, i32* %5
%8 = icmp sge i32 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %2
br label %10
10: ; preds = %9, %2
%11 = phi i1 [ false, %2 ], [ true, %9 ]
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = load i32, i32* %5
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %10
%17 = load i8*, i8** %4
store i8* %17, i8** %3
br label %64
18: ; preds = %10
br label %19
19: ; preds = %51, %18
%20 = load i32, i32* %6
%21 = load i32, i32* %5
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %28
23: ; preds = %19
%24 = load i8*, i8** %4
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %26, 0
br label %28
28: ; preds = %23, %19
%29 = phi i1 [ false, %19 ], [ %27, %23 ]
br i1 %29, label %30, label %54
30: ; preds = %28
%31 = load i8*, i8** %4
%32 = getelementptr inbounds i8, i8* %31, i64 0
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 37
br i1 %35, label %36, label %51
36: ; preds = %30
%37 = load i8*, i8** %4
%38 = getelementptr inbounds i8, i8* %37, i64 1
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp eq i32 %40, 37
br i1 %41, label %42, label %51
42: ; preds = %36
%43 = load i8*, i8** %4
%44 = getelementptr inbounds i8, i8* %43, i64 2
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = icmp eq i32 %46, 10
br i1 %47, label %48, label %51
48: ; preds = %42
%49 = load i32, i32* %6
%50 = add nsw i32 %49, 1
store i32 %50, i32* %6
br label %51
51: ; preds = %48, %42, %36, %30
%52 = load i8*, i8** %4
%53 = getelementptr inbounds i8, i8* %52, i32 1
store i8* %53, i8** %4
br label %19
54: ; preds = %28
%55 = load i8*, i8** %4
%56 = load i8, i8* %55
%57 = sext i8 %56 to i32
%58 = icmp ne i32 %57, 0
br i1 %58, label %59, label %62
59: ; preds = %54
%60 = load i8*, i8** %4
%61 = getelementptr inbounds i8, i8* %60, i64 2
store i8* %61, i8** %3
br label %64
62: ; preds = %54
%63 = load i8*, i8** %4
store i8* %63, i8** %3
br label %64
64: ; preds = %62, %59, %16
%65 = load i8*, i8** %3
ret i8* %65
}

LLVM IR (-O2):
define i8* @find_section_start(i8* %0, i32 %1) {
%3 = xor i32 %1, -1
%4 = lshr i32 %3, 31
%5 = tail call i32 @assert(i32 %4)
%6 = icmp eq i32 %1, 0
br i1 %6, label %33, label %7
7: ; preds = %2
%8 = icmp sgt i32 %1, 0
br i1 %8, label %9, label %27
9: ; preds = %7, %23
%10 = phi i32 [ %24, %23 ], [ 0, %7 ]
%11 = phi i8* [ %25, %23 ], [ %0, %7 ]
%12 = load i8, i8* %11
switch i8 %12, label %23 [
i8 0, label %27
i8 37, label %13
]
13: ; preds = %9
%14 = getelementptr inbounds i8, i8* %11, i64 1
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 37
br i1 %16, label %17, label %23
17: ; preds = %13
%18 = getelementptr inbounds i8, i8* %11, i64 2
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 10
%21 = zext i1 %20 to i32
%22 = add nsw i32 %10, %21
br label %23
23: ; preds = %17, %9, %13
%24 = phi i32 [ %10, %13 ], [ %10, %9 ], [ %22, %17 ]
%25 = getelementptr inbounds i8, i8* %11, i64 1
%26 = icmp slt i32 %24, %1
br i1 %26, label %9, label %27
27: ; preds = %23, %9, %7
%28 = phi i8* [ %0, %7 ], [ %11, %9 ], [ %25, %23 ]
%29 = load i8, i8* %28
%30 = icmp eq i8 %29, 0
%31 = select i1 %30, i64 0, i64 2
%32 = getelementptr i8, i8* %28, i64 %31
br label %33
33: ; preds = %27, %2
%34 = phi i8* [ %0, %2 ], [ %32, %27 ]
ret i8* %34
}