#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 timeval {
  int dummy;
};
struct katcl_parse {
  int dummy;
};
struct katcl_line {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ append_parse_katcl(struct katcl_line *,
                                      struct katcl_parse *);
int complete_rpc_katcl(struct katcl_line *, int /*<<< orphan*/,
                       struct timeval *);
char *get_string_parse_katcl(struct katcl_parse *, int /*<<< orphan*/);
scalar_t__ is_inform_parse_katcl(struct katcl_parse *);
struct katcl_parse *ready_katcl(struct katcl_line *);
int /*<<< orphan*/ strcmp(char *, char *);
int complete_with_log(struct katcl_line *l, struct timeval *until,
                      struct katcl_line *k) {
  struct katcl_parse *px;
  int result;
  char *ptr;
  while ((result = complete_rpc_katcl(l, 0, until)) == 0) {
    px = ready_katcl(l);
    if (px) {
      if (is_inform_parse_katcl(px)) {
        ptr = get_string_parse_katcl(px, 0);
        if (!strcmp("#log", ptr)) {
          append_parse_katcl(k, px);
        }
      }
    }
  }
  return result;
}


x86 assembly (clang, -O0):
<complete_with_log>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
xor    %esi,%esi
call   1080 <complete_rpc_katcl@plt>
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
jne    11fe <complete_with_log+0x9e>
mov    -0x8(%rbp),%rdi
call   1030 <ready_katcl@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11f9 <complete_with_log+0x99>
mov    -0x20(%rbp),%rdi
call   1060 <is_inform_parse_katcl@plt>
cmp    $0x0,%rax
je     11f4 <complete_with_log+0x94>
mov    -0x20(%rbp),%rdi
xor    %esi,%esi
call   1040 <get_string_parse_katcl@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rsi
lea    0xe2c(%rip),%rdi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    11ef <complete_with_log+0x8f>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <append_parse_katcl@plt>
jmp    11f4 <complete_with_log+0x94>
jmp    11f9 <complete_with_log+0x99>
jmp    1174 <complete_with_log+0x14>
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<complete_with_log>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r13
xor    %esi,%esi
mov    %r15,%rdx
call   1080 <complete_rpc_katcl@plt>
test   %eax,%eax
je     118a <complete_with_log+0x2a>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0xe6f(%rip),%r12
jmp    11b1 <complete_with_log+0x51>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r13,%rdi
xor    %esi,%esi
mov    %r15,%rdx
call   1080 <complete_rpc_katcl@plt>
test   %eax,%eax
jne    1180 <complete_with_log+0x20>
mov    %r13,%rdi
call   1030 <ready_katcl@plt>
test   %rax,%rax
je     11a0 <complete_with_log+0x40>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <is_inform_parse_katcl@plt>
test   %rax,%rax
je     11a0 <complete_with_log+0x40>
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <get_string_parse_katcl@plt>
mov    %r12,%rdi
mov    %rax,%rsi
call   1070 <strcmp@plt>
test   %eax,%eax
jne    11a0 <complete_with_log+0x40>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <append_parse_katcl@plt>
jmp    11a0 <complete_with_log+0x40>

LLVM IR (-O0):
%struct.timeval = type { i32 }
%struct.katcl_line = type { i32 }
%struct.katcl_parse = type { i32 }
@.str = [5 x i8] c"#log\00"
define i32 @complete_with_log(%struct.katcl_line* %0, %struct.timeval* %1, %struct.katcl_line* %2) {
%4 = alloca %struct.katcl_line*
%5 = alloca %struct.timeval*
%6 = alloca %struct.katcl_line*
%7 = alloca %struct.katcl_parse*
%8 = alloca i32
%9 = alloca i8*
store %struct.katcl_line* %0, %struct.katcl_line** %4
store %struct.timeval* %1, %struct.timeval** %5
store %struct.katcl_line* %2, %struct.katcl_line** %6
br label %10
10: ; preds = %36, %3
%11 = load %struct.katcl_line*, %struct.katcl_line** %4
%12 = load %struct.timeval*, %struct.timeval** %5
%13 = call i32 @complete_rpc_katcl(%struct.katcl_line* %11, i32 0, %struct.timeval* %12)
store i32 %13, i32* %8
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %37
15: ; preds = %10
%16 = load %struct.katcl_line*, %struct.katcl_line** %4
%17 = call %struct.katcl_parse* @ready_katcl(%struct.katcl_line* %16)
store %struct.katcl_parse* %17, %struct.katcl_parse** %7
%18 = load %struct.katcl_parse*, %struct.katcl_parse** %7
%19 = icmp ne %struct.katcl_parse* %18, null
br i1 %19, label %20, label %36
20: ; preds = %15
%21 = load %struct.katcl_parse*, %struct.katcl_parse** %7
%22 = call i64 @is_inform_parse_katcl(%struct.katcl_parse* %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %35
24: ; preds = %20
%25 = load %struct.katcl_parse*, %struct.katcl_parse** %7
%26 = call i8* @get_string_parse_katcl(%struct.katcl_parse* %25, i32 0)
store i8* %26, i8** %9
%27 = load i8*, i8** %9
%28 = call i32 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %27)
%29 = icmp ne i32 %28, 0
br i1 %29, label %34, label %30
30: ; preds = %24
%31 = load %struct.katcl_line*, %struct.katcl_line** %6
%32 = load %struct.katcl_parse*, %struct.katcl_parse** %7
%33 = call i32 @append_parse_katcl(%struct.katcl_line* %31, %struct.katcl_parse* %32)
br label %34
34: ; preds = %30, %24
br label %35
35: ; preds = %34, %20
br label %36
36: ; preds = %35, %15
br label %10
37: ; preds = %10
%38 = load i32, i32* %8
ret i32 %38
}

LLVM IR (-O2):
%struct.timeval = type { i32 }
%struct.katcl_line = type { i32 }
%struct.katcl_parse = type { i32 }
@.str = [5 x i8] c"#log\00"
define i32 @complete_with_log(%struct.katcl_line* %0, %struct.timeval* %1, %struct.katcl_line* %2) {
%4 = tail call i32 @complete_rpc_katcl(%struct.katcl_line* %0, i32 0, %struct.timeval* %1)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %21
6: ; preds = %3, %18
%7 = tail call %struct.katcl_parse* @ready_katcl(%struct.katcl_line* %0)
%8 = icmp eq %struct.katcl_parse* %7, null
br i1 %8, label %18, label %9
9: ; preds = %6
%10 = tail call i64 @is_inform_parse_katcl(%struct.katcl_parse* %7)
%11 = icmp eq i64 %10, 0
br i1 %11, label %18, label %12
12: ; preds = %9
%13 = tail call i8* @get_string_parse_katcl(%struct.katcl_parse* %7, i32 0)
%14 = tail call i32 @strcmp(i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* dereferenceable(1) %13)
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = tail call i32 @append_parse_katcl(%struct.katcl_line* %2, %struct.katcl_parse* %7)
br label %18
18: ; preds = %9, %16, %12, %6
%19 = tail call i32 @complete_rpc_katcl(%struct.katcl_line* %0, i32 0, %struct.timeval* %1)
%20 = icmp eq i32 %19, 0
br i1 %20, label %6, label %21
21: ; preds = %18, %3
%22 = phi i32 [ %4, %3 ], [ %19, %18 ]
ret i32 %22
}