#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 */
char *flon_exid_path(char *);
float flu_fstat(char *);
char *flu_pline(char *, char *);
char *flu_sprintf(char *, char *);
int /*<<< orphan*/ free(char *);
size_t strtoll(char *, int /*<<< orphan*/ *, int);
size_t hlp_count_msgs(char *exid) {
  char *fep = flon_exid_path(exid);
  char *fpath = flu_sprintf("var/run/%s/msg.log", fep);
  if (flu_fstat(fpath) != 'f') {
    free(fpath);
    fpath = flu_sprintf("var/archive/%s/msg.log", fep);
  }
  char *lc = flu_pline("wc -l %s", fpath);
  size_t r = strtoll(lc, NULL, 10);
  free(lc);
  free(fep);
  free(fpath);
  return r;
}


x86 assembly (clang, -O0):
<hlp_count_msgs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <flon_exid_path@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe80(%rip),%rdi
call   1050 <flu_sprintf@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <flu_fstat@plt>
movss  0xe62(%rip),%xmm1
ucomiss %xmm1,%xmm0
jne    11b2 <hlp_count_msgs+0x52>
jp     11b2 <hlp_count_msgs+0x52>
jmp    11cf <hlp_count_msgs+0x6f>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rsi
lea    0xe51(%rip),%rdi
call   1050 <flu_sprintf@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe54(%rip),%rdi
call   1080 <flu_pline@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1060 <strtoll@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hlp_count_msgs>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
call   1040 <flon_exid_path@plt>
mov    %rax,%r14
lea    0xe8d(%rip),%rdi
mov    %rax,%rsi
call   1050 <flu_sprintf@plt>
mov    %rax,%r15
mov    %rax,%rdi
call   1070 <flu_fstat@plt>
ucomiss 0xe6f(%rip),%xmm0
jne    1195 <hlp_count_msgs+0x35>
jnp    11af <hlp_count_msgs+0x4f>
mov    %r15,%rdi
call   1030 <free@plt>
lea    0xe73(%rip),%rdi
mov    %r14,%rsi
call   1050 <flu_sprintf@plt>
mov    %rax,%r15
lea    0xe78(%rip),%rdi
mov    %r15,%rsi
call   1080 <flu_pline@plt>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1060 <strtoll@plt>
mov    %rax,%r12
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r12,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [19 x i8] c"var/run/%s/msg.log\00"
@.str.1 = [23 x i8] c"var/archive/%s/msg.log\00"
@.str.2 = [9 x i8] c"wc -l %s\00"
define i64 @hlp_count_msgs(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
store i8* %0, i8** %2
%7 = load i8*, i8** %2
%8 = call i8* @flon_exid_path(i8* %7)
store i8* %8, i8** %3
%9 = load i8*, i8** %3
%10 = call i8* @flu_sprintf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %9)
store i8* %10, i8** %4
%11 = load i8*, i8** %4
%12 = call float @flu_fstat(i8* %11)
%13 = fcmp une float %12, 1.020000e+02
br i1 %13, label %14, label %19
14: ; preds = %1
%15 = load i8*, i8** %4
%16 = call i32 @free(i8* %15)
%17 = load i8*, i8** %3
%18 = call i8* @flu_sprintf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %17)
store i8* %18, i8** %4
br label %19
19: ; preds = %14, %1
%20 = load i8*, i8** %4
%21 = call i8* @flu_pline(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %20)
store i8* %21, i8** %5
%22 = load i8*, i8** %5
%23 = call i64 @strtoll(i8* %22, i32* null, i32 10)
store i64 %23, i64* %6
%24 = load i8*, i8** %5
%25 = call i32 @free(i8* %24)
%26 = load i8*, i8** %3
%27 = call i32 @free(i8* %26)
%28 = load i8*, i8** %4
%29 = call i32 @free(i8* %28)
%30 = load i64, i64* %6
ret i64 %30
}

LLVM IR (-O2):
@.str = [19 x i8] c"var/run/%s/msg.log\00"
@.str.1 = [23 x i8] c"var/archive/%s/msg.log\00"
@.str.2 = [9 x i8] c"wc -l %s\00"
define i64 @hlp_count_msgs(i8* %0) {
%2 = tail call i8* @flon_exid_path(i8* %0)
%3 = tail call i8* @flu_sprintf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %2)
%4 = tail call float @flu_fstat(i8* %3)
%5 = fcmp une float %4, 1.020000e+02
br i1 %5, label %6, label %9
6: ; preds = %1
%7 = tail call i32 @free(i8* %3)
%8 = tail call i8* @flu_sprintf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %2)
br label %9
9: ; preds = %6, %1
%10 = phi i8* [ %8, %6 ], [ %3, %1 ]
%11 = tail call i8* @flu_pline(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %10)
%12 = tail call i64 @strtoll(i8* nocapture %11, i32* null, i32 10)
%13 = tail call i32 @free(i8* %11)
%14 = tail call i32 @free(i8* %2)
%15 = tail call i32 @free(i8* %10)
ret i64 %12
}