#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*/ mgetstring();
unsigned long mgetuleb128();
int /*<<< orphan*/ mputstring(int /*<<< orphan*/);
int /*<<< orphan*/ mputuleb128(unsigned long);
scalar_t__ msynch();
long function_names(void) {
  long delta = 0;
  unsigned long count;
  mputstring(mgetstring());
  delta += msynch();
  mputuleb128(count = mgetuleb128());
  delta += msynch();
  while (count--) {
    mputstring(mgetstring());
    delta += msynch();
  }
  return delta;
}


x86 assembly (clang, -O0):
<function_names>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movq   $0x0,-0x8(%rbp)
mov    $0x0,%al
call   1070 <mgetstring@plt>
mov    %eax,%edi
call   1030 <mputstring@plt>
mov    $0x0,%al
call   1060 <msynch@plt>
add    -0x8(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    $0x0,%al
call   1040 <mgetuleb128@plt>
mov    %rax,%rdi
mov    %rdi,-0x10(%rbp)
call   1050 <mputuleb128@plt>
mov    $0x0,%al
call   1060 <msynch@plt>
add    -0x8(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x10(%rbp)
cmp    $0x0,%rax
je     11da <function_names+0x8a>
mov    $0x0,%al
call   1070 <mgetstring@plt>
mov    %eax,%edi
call   1030 <mputstring@plt>
mov    $0x0,%al
call   1060 <msynch@plt>
add    -0x8(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    119f <function_names+0x4f>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<function_names>:
push   %r15
push   %r14
push   %rbx
xor    %eax,%eax
call   1070 <mgetstring@plt>
mov    %eax,%edi
call   1030 <mputstring@plt>
xor    %eax,%eax
call   1060 <msynch@plt>
mov    %rax,%r15
xor    %eax,%eax
call   1040 <mgetuleb128@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1050 <mputuleb128@plt>
xor    %eax,%eax
call   1060 <msynch@plt>
mov    %rax,%rbx
add    %r15,%rbx
test   %r14,%r14
je     11be <function_names+0x6e>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1070 <mgetstring@plt>
mov    %eax,%edi
call   1030 <mputstring@plt>
xor    %eax,%eax
call   1060 <msynch@plt>
add    %rax,%rbx
add    $0xffffffffffffffff,%r14
jne    11a0 <function_names+0x50>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @function_names() {
%1 = alloca i64
%2 = alloca i64
store i64 0, i64* %1
%3 = call i32 (...) @mgetstring()
%4 = call i32 @mputstring(i32 %3)
%5 = call i64 (...) @msynch()
%6 = load i64, i64* %1
%7 = add nsw i64 %6, %5
store i64 %7, i64* %1
%8 = call i64 (...) @mgetuleb128()
store i64 %8, i64* %2
%9 = call i32 @mputuleb128(i64 %8)
%10 = call i64 (...) @msynch()
%11 = load i64, i64* %1
%12 = add nsw i64 %11, %10
store i64 %12, i64* %1
br label %13
13: ; preds = %17, %0
%14 = load i64, i64* %2
%15 = add i64 %14, -1
store i64 %15, i64* %2
%16 = icmp ne i64 %14, 0
br i1 %16, label %17, label %23
17: ; preds = %13
%18 = call i32 (...) @mgetstring()
%19 = call i32 @mputstring(i32 %18)
%20 = call i64 (...) @msynch()
%21 = load i64, i64* %1
%22 = add nsw i64 %21, %20
store i64 %22, i64* %1
br label %13
23: ; preds = %13
%24 = load i64, i64* %1
ret i64 %24
}

LLVM IR (-O2):
define i64 @function_names() {
%1 = tail call i32 (...) @mgetstring()
%2 = tail call i32 @mputstring(i32 %1)
%3 = tail call i64 (...) @msynch()
%4 = tail call i64 (...) @mgetuleb128()
%5 = tail call i32 @mputuleb128(i64 %4)
%6 = tail call i64 (...) @msynch()
%7 = add nsw i64 %6, %3
%8 = icmp eq i64 %4, 0
br i1 %8, label %18, label %9
9: ; preds = %0, %9
%10 = phi i64 [ %12, %9 ], [ %4, %0 ]
%11 = phi i64 [ %16, %9 ], [ %7, %0 ]
%12 = add i64 %10, -1
%13 = tail call i32 (...) @mgetstring()
%14 = tail call i32 @mputstring(i32 %13)
%15 = tail call i64 (...) @msynch()
%16 = add nsw i64 %15, %11
%17 = icmp eq i64 %12, 0
br i1 %17, label %18, label %9
18: ; preds = %9, %0
%19 = phi i64 [ %7, %0 ], [ %16, %9 ]
ret i64 %19
}