#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 */
struct patchpool {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ patchpool_add(struct patchpool *, char *);
char *strndup(char const *, int);
void patchpool_add_multi(struct patchpool *pp, const char *entry) {
  int offset;
  char *e;
  while (1) {
    offset = 0;
    while ((entry[offset] != '\n') && (entry[offset] != 0))
      offset++;
    if (offset != 0) {
      e = strndup(entry, offset);
      patchpool_add(pp, e);
    }
    if (entry[offset] == 0)
      break;
    else
      entry += offset + 1;
  }
}


x86 assembly (clang, -O0):
<patchpool_add_multi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x21(%rbp)
je     1166 <patchpool_add_multi+0x46>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1176 <patchpool_add_multi+0x56>
jmp    1184 <patchpool_add_multi+0x64>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1137 <patchpool_add_multi+0x17>
cmpl   $0x0,-0x14(%rbp)
je     11ab <patchpool_add_multi+0x8b>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <strndup@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <patchpool_add@plt>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
jne    11c5 <patchpool_add_multi+0xa5>
jmp    11de <patchpool_add_multi+0xbe>
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
jmp    1130 <patchpool_add_multi+0x10>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<patchpool_add_multi>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
nopl   0x0(%rax,%rax,1)
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl (%r15,%rbx,1),%eax
test   %al,%al
je     1160 <patchpool_add_multi+0x40>
cmp    $0xa,%al
je     1160 <patchpool_add_multi+0x40>
add    $0x1,%rbx
jmp    1140 <patchpool_add_multi+0x20>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
test   %ebx,%ebx
je     1179 <patchpool_add_multi+0x59>
mov    %r15,%rdi
mov    %ebx,%esi
call   1040 <strndup@plt>
mov    %r14,%rdi
mov    %rax,%rsi
call   1030 <patchpool_add@plt>
mov    %ebx,%eax
cmpb   $0x0,(%r15,%rax,1)
je     118a <patchpool_add_multi+0x6a>
add    $0x1,%ebx
add    %rbx,%r15
jmp    1130 <patchpool_add_multi+0x10>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.patchpool = type { i32 }
define void @patchpool_add_multi(%struct.patchpool* %0, i8* %1) {
%3 = alloca %struct.patchpool*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
store %struct.patchpool* %0, %struct.patchpool** %3
store i8* %1, i8** %4
br label %7
7: ; preds = %2, %54
store i32 0, i32* %5
br label %8
8: ; preds = %26, %7
%9 = load i8*, i8** %4
%10 = load i32, i32* %5
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %9, i64 %11
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 10
br i1 %15, label %16, label %24
16: ; preds = %8
%17 = load i8*, i8** %4
%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 ne i32 %22, 0
br label %24
24: ; preds = %16, %8
%25 = phi i1 [ false, %8 ], [ %23, %16 ]
br i1 %25, label %26, label %29
26: ; preds = %24
%27 = load i32, i32* %5
%28 = add nsw i32 %27, 1
store i32 %28, i32* %5
br label %8
29: ; preds = %24
%30 = load i32, i32* %5
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %39
32: ; preds = %29
%33 = load i8*, i8** %4
%34 = load i32, i32* %5
%35 = call i8* @strndup(i8* %33, i32 %34)
store i8* %35, i8** %6
%36 = load %struct.patchpool*, %struct.patchpool** %3
%37 = load i8*, i8** %6
%38 = call i32 @patchpool_add(%struct.patchpool* %36, i8* %37)
br label %39
39: ; preds = %32, %29
%40 = load i8*, i8** %4
%41 = load i32, i32* %5
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %40, i64 %42
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = icmp eq i32 %45, 0
br i1 %46, label %47, label %48
47: ; preds = %39
br label %55
48: ; preds = %39
%49 = load i32, i32* %5
%50 = add nsw i32 %49, 1
%51 = load i8*, i8** %4
%52 = sext i32 %50 to i64
%53 = getelementptr inbounds i8, i8* %51, i64 %52
store i8* %53, i8** %4
br label %54
54: ; preds = %48
br label %7
55: ; preds = %47
ret void
}

LLVM IR (-O2):
%struct.patchpool = type { i32 }
define void @patchpool_add_multi(%struct.patchpool* %0, i8* nocapture %1) {
br label %3
3: ; preds = %22, %2
%4 = phi i8* [ %1, %2 ], [ %25, %22 ]
br label %5
5: ; preds = %9, %3
%6 = phi i64 [ %10, %9 ], [ 0, %3 ]
%7 = getelementptr inbounds i8, i8* %4, i64 %6
%8 = load i8, i8* %7
switch i8 %8, label %9 [
i8 10, label %11
i8 0, label %11
]
9: ; preds = %5
%10 = add nuw i64 %6, 1
br label %5
11: ; preds = %5, %5
%12 = trunc i64 %6 to i32
%13 = and i64 %6, 4294967295
%14 = getelementptr inbounds i8, i8* %4, i64 %13
%15 = icmp eq i32 %12, 0
br i1 %15, label %19, label %16
16: ; preds = %11
%17 = tail call i8* @strndup(i8* %4, i32 %12)
%18 = tail call i32 @patchpool_add(%struct.patchpool* %0, i8* %17)
br label %19
19: ; preds = %16, %11
%20 = load i8, i8* %14
%21 = icmp eq i8 %20, 0
br i1 %21, label %26, label %22
22: ; preds = %19
%23 = add i64 %6, 1
%24 = and i64 %23, 4294967295
%25 = getelementptr inbounds i8, i8* %4, i64 %24
br label %3
26: ; preds = %19
ret void
}