#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 strlen(char *);
void debian_parse_changelog_header(char *linestr, char *version) {
  int i, found = 0, ctr = 0;
  version[0] = 0;
  for (i = 0; i < strlen(linestr) - 1; i++) {
    if (linestr[i] == '(') {
      found = 1;
    } else {
      if (linestr[i] == ')') {
        found = 0;
        version[ctr] = 0;
      }
      if (found == 1) {
        version[ctr++] = linestr[i];
      }
    }
  }
}


x86 assembly (clang, -O0):
<debian_parse_changelog_header>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11e6 <debian_parse_changelog_header+0xd6>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x28,%eax
jne    117c <debian_parse_changelog_header+0x6c>
movl   $0x1,-0x18(%rbp)
jmp    11d3 <debian_parse_changelog_header+0xc3>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x29,%eax
jne    11a4 <debian_parse_changelog_header+0x94>
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
cmpl   $0x1,-0x18(%rbp)
jne    11ce <debian_parse_changelog_header+0xbe>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x1c(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
jmp    11d3 <debian_parse_changelog_header+0xc3>
jmp    11d8 <debian_parse_changelog_header+0xc8>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113c <debian_parse_changelog_header+0x2c>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<debian_parse_changelog_header>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
movb   $0x0,(%rsi)
call   1030 <strlen@plt>
cmp    $0x2,%eax
jl     11a7 <debian_parse_changelog_header+0x97>
xor    %ebx,%ebx
xor    %r12d,%r12d
xor    %eax,%eax
jmp    1163 <debian_parse_changelog_header+0x53>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movslq %r12d,%rax
mov    %sil,(%r14,%rax,1)
mov    %edx,%r12d
add    $0x1,%rbx
mov    %r15,%rdi
call   1030 <strlen@plt>
add    $0xffffffff,%eax
movslq %eax,%rcx
mov    %ebp,%eax
cmp    %rcx,%rbx
jge    11a7 <debian_parse_changelog_header+0x97>
movzbl (%r15,%rbx,1),%ecx
cmp    $0x28,%cl
je     11a0 <debian_parse_changelog_header+0x90>
mov    $0x0,%esi
mov    $0x0,%ebp
mov    %r12d,%edx
cmp    $0x29,%cl
je     1140 <debian_parse_changelog_header+0x30>
xor    %ebp,%ebp
cmp    $0x1,%eax
jne    114a <debian_parse_changelog_header+0x3a>
lea    0x1(%r12),%edx
mov    $0x1,%ebp
mov    %ecx,%esi
jmp    1140 <debian_parse_changelog_header+0x30>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x1,%ebp
jmp    114a <debian_parse_changelog_header+0x3a>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @debian_parse_changelog_header(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 0, i32* %6
store i32 0, i32* %7
%8 = load i8*, i8** %4
%9 = getelementptr inbounds i8, i8* %8, i64 0
store i8 0, i8* %9
store i32 0, i32* %5
br label %10
10: ; preds = %54, %2
%11 = load i32, i32* %5
%12 = load i8*, i8** %3
%13 = call i32 @strlen(i8* %12)
%14 = sub nsw i32 %13, 1
%15 = icmp slt i32 %11, %14
br i1 %15, label %16, label %57
16: ; preds = %10
%17 = load i8*, i8** %3
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 40
br i1 %23, label %24, label %25
24: ; preds = %16
store i32 1, i32* %6
br label %53
25: ; preds = %16
%26 = load i8*, i8** %3
%27 = load i32, i32* %5
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 41
br i1 %32, label %33, label %38
33: ; preds = %25
store i32 0, i32* %6
%34 = load i8*, i8** %4
%35 = load i32, i32* %7
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %34, i64 %36
store i8 0, i8* %37
br label %38
38: ; preds = %33, %25
%39 = load i32, i32* %6
%40 = icmp eq i32 %39, 1
br i1 %40, label %41, label %52
41: ; preds = %38
%42 = load i8*, i8** %3
%43 = load i32, i32* %5
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* %42, i64 %44
%46 = load i8, i8* %45
%47 = load i8*, i8** %4
%48 = load i32, i32* %7
%49 = add nsw i32 %48, 1
store i32 %49, i32* %7
%50 = sext i32 %48 to i64
%51 = getelementptr inbounds i8, i8* %47, i64 %50
store i8 %46, i8* %51
br label %52
52: ; preds = %41, %38
br label %53
53: ; preds = %52, %24
br label %54
54: ; preds = %53
%55 = load i32, i32* %5
%56 = add nsw i32 %55, 1
store i32 %56, i32* %5
br label %10
57: ; preds = %10
ret void
}

LLVM IR (-O2):
define void @debian_parse_changelog_header(i8* %0, i8* nocapture writeonly %1) {
store i8 0, i8* %1
%3 = tail call i32 @strlen(i8* %0)
%4 = icmp sgt i32 %3, 1
br i1 %4, label %5, label %29
5: ; preds = %2, %21
%6 = phi i64 [ %24, %21 ], [ 0, %2 ]
%7 = phi i32 [ %23, %21 ], [ 0, %2 ]
%8 = phi i32 [ %22, %21 ], [ 0, %2 ]
%9 = getelementptr inbounds i8, i8* %0, i64 %6
%10 = load i8, i8* %9
switch i8 %10, label %11 [
i8 40, label %21
i8 41, label %15
]
11: ; preds = %5
%12 = icmp eq i32 %8, 1
br i1 %12, label %13, label %21
13: ; preds = %11
%14 = add nsw i32 %7, 1
br label %15
15: ; preds = %5, %13
%16 = phi i8 [ %10, %13 ], [ 0, %5 ]
%17 = phi i32 [ 1, %13 ], [ 0, %5 ]
%18 = phi i32 [ %14, %13 ], [ %7, %5 ]
%19 = sext i32 %7 to i64
%20 = getelementptr inbounds i8, i8* %1, i64 %19
store i8 %16, i8* %20
br label %21
21: ; preds = %15, %5, %11
%22 = phi i32 [ 0, %11 ], [ 1, %5 ], [ %17, %15 ]
%23 = phi i32 [ %7, %11 ], [ %7, %5 ], [ %18, %15 ]
%24 = add nuw nsw i64 %6, 1
%25 = tail call i32 @strlen(i8* %0)
%26 = add nsw i32 %25, -1
%27 = sext i32 %26 to i64
%28 = icmp slt i64 %24, %27
br i1 %28, label %5, label %29
29: ; preds = %21, %2
ret void
}