#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 byg_end(char *, char *);
int /*<<< orphan*/ byg_start(char *, char *);
int count_sequences_stockholm(char *string) {
  char *p1 = string;
  int i = 0;
  int j = 0;
  int n = 0;
  while ((i = byg_end("\n", p1)) != -1) {
    p1 += i;
    if (!(byg_start("//", p1))) {
      break;
    }
    j = byg_end("#", p1);
    if (j != 1) {
      n++;
    }
  }
  if (!n) {
    return 0;
  }
  return n;
}


x86 assembly (clang, -O0):
<count_sequences_stockholm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xeac(%rip),%rdi
call   1030 <byg_end@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0xffffffff,%eax
je     11bf <count_sequences_stockholm+0x9f>
mov    -0x1c(%rbp),%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe81(%rip),%rdi
call   1040 <byg_start@plt>
cmp    $0x0,%eax
jne    1194 <count_sequences_stockholm+0x74>
jmp    11bf <count_sequences_stockholm+0x9f>
mov    -0x18(%rbp),%rsi
lea    0xe66(%rip),%rdi
call   1030 <byg_end@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x1,-0x20(%rbp)
je     11ba <count_sequences_stockholm+0x9a>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1149 <count_sequences_stockholm+0x29>
cmpl   $0x0,-0x24(%rbp)
jne    11d5 <count_sequences_stockholm+0xb5>
movl   $0x0,-0x4(%rbp)
jmp    11db <count_sequences_stockholm+0xbb>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<count_sequences_stockholm>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%rbx
lea    0xece(%rip),%rdi
mov    %rbx,%rsi
call   1030 <byg_end@plt>
xor    %ebp,%ebp
cmp    $0xffffffff,%eax
je     119d <count_sequences_stockholm+0x7d>
lea    0xeba(%rip),%r14
lea    0xeb6(%rip),%r15
lea    0xeaa(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rcx
movslq %eax,%rbx
add    %rcx,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <byg_start@plt>
test   %eax,%eax
je     119d <count_sequences_stockholm+0x7d>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <byg_end@plt>
xor    %ecx,%ecx
cmp    $0x1,%eax
setne  %cl
add    %ecx,%ebp
mov    %r12,%rdi
mov    %rbx,%rsi
call   1030 <byg_end@plt>
cmp    $0xffffffff,%eax
jne    1160 <count_sequences_stockholm+0x40>
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [3 x i8] c"//\00"
@.str.2 = [2 x i8] c"#\00"
define i32 @count_sequences_stockholm(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
%8 = load i8*, i8** %3
store i8* %8, i8** %4
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
br label %9
9: ; preds = %30, %1
%10 = load i8*, i8** %4
%11 = call i32 @byg_end(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* %10)
store i32 %11, i32* %5
%12 = icmp ne i32 %11, -1
br i1 %12, label %13, label %31
13: ; preds = %9
%14 = load i32, i32* %5
%15 = load i8*, i8** %4
%16 = sext i32 %14 to i64
%17 = getelementptr inbounds i8, i8* %15, i64 %16
store i8* %17, i8** %4
%18 = load i8*, i8** %4
%19 = call i32 @byg_start(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %18)
%20 = icmp ne i32 %19, 0
br i1 %20, label %22, label %21
21: ; preds = %13
br label %31
22: ; preds = %13
%23 = load i8*, i8** %4
%24 = call i32 @byg_end(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* %23)
store i32 %24, i32* %6
%25 = load i32, i32* %6
%26 = icmp ne i32 %25, 1
br i1 %26, label %27, label %30
27: ; preds = %22
%28 = load i32, i32* %7
%29 = add nsw i32 %28, 1
store i32 %29, i32* %7
br label %30
30: ; preds = %27, %22
br label %9
31: ; preds = %21, %9
%32 = load i32, i32* %7
%33 = icmp ne i32 %32, 0
br i1 %33, label %35, label %34
34: ; preds = %31
store i32 0, i32* %2
br label %37
35: ; preds = %31
%36 = load i32, i32* %7
store i32 %36, i32* %2
br label %37
37: ; preds = %35, %34
%38 = load i32, i32* %2
ret i32 %38
}

LLVM IR (-O2):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [3 x i8] c"//\00"
@.str.2 = [2 x i8] c"#\00"
define i32 @count_sequences_stockholm(i8* %0) {
%2 = tail call i32 @byg_end(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* %0)
%3 = icmp eq i32 %2, -1
br i1 %3, label %19, label %4
4: ; preds = %1, %12
%5 = phi i32 [ %17, %12 ], [ %2, %1 ]
%6 = phi i32 [ %16, %12 ], [ 0, %1 ]
%7 = phi i8* [ %9, %12 ], [ %0, %1 ]
%8 = sext i32 %5 to i64
%9 = getelementptr inbounds i8, i8* %7, i64 %8
%10 = tail call i32 @byg_start(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = icmp eq i32 %10, 0
br i1 %11, label %19, label %12
12: ; preds = %4
%13 = tail call i32 @byg_end(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* %9)
%14 = icmp ne i32 %13, 1
%15 = zext i1 %14 to i32
%16 = add nuw nsw i32 %6, %15
%17 = tail call i32 @byg_end(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* %9)
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %4
19: ; preds = %12, %4, %1
%20 = phi i32 [ 0, %1 ], [ %6, %4 ], [ %16, %12 ]
ret i32 %20
}