#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*/ add_one_size(char *, size_t);
int /*<<< orphan*/ strcpy(char *, char const *);
char *strrchr(char *, char);
void add_size(const char *name, size_t size) {
  char tmpl[128], *p;
  strcpy(tmpl, name);
  add_one_size(tmpl, size);
  while (p = strrchr(tmpl, '/')) {
    *p = '\0';
    add_one_size(tmpl, size);
  }
}


x86 assembly (clang, -O0):
<add_size>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x90(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x90(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <add_one_size@plt>
lea    -0x90(%rbp),%rdi
mov    $0x2f,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x98(%rbp)
cmp    $0x0,%rax
je     11a4 <add_size+0x74>
mov    -0x98(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x90(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <add_one_size@plt>
jmp    1163 <add_size+0x33>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_size>:
push   %r14
push   %rbx
sub    $0x88,%rsp
mov    %rsi,%r14
mov    %rdi,%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <add_one_size@plt>
mov    %rbx,%rdi
mov    $0x2f,%esi
call   1040 <strrchr@plt>
test   %rax,%rax
je     1190 <add_size+0x60>
mov    %rsp,%rbx
nopl   0x0(%rax,%rax,1)
movb   $0x0,(%rax)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <add_one_size@plt>
mov    %rbx,%rdi
mov    $0x2f,%esi
call   1040 <strrchr@plt>
test   %rax,%rax
jne    1170 <add_size+0x40>
add    $0x88,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @add_size(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca [128 x i8]
%6 = alloca i8*
store i8* %0, i8** %3
store i64 %1, i64* %4
%7 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%8 = load i8*, i8** %3
%9 = call i32 @strcpy(i8* %7, i8* %8)
%10 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%11 = load i64, i64* %4
%12 = call i32 @add_one_size(i8* %10, i64 %11)
br label %13
13: ; preds = %17, %2
%14 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%15 = call i8* @strrchr(i8* %14, i8 signext 47)
store i8* %15, i8** %6
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %22
17: ; preds = %13
%18 = load i8*, i8** %6
store i8 0, i8* %18
%19 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%20 = load i64, i64* %4
%21 = call i32 @add_one_size(i8* %19, i64 %20)
br label %13
22: ; preds = %13
ret void
}

LLVM IR (-O2):
define void @add_size(i8* %0, i64 %1) {
%3 = alloca [128 x i8]
%4 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%5 = call i32 @strcpy(i8* %4, i8* %0)
%6 = call i32 @add_one_size(i8* %4, i64 %1)
%7 = call i8* @strrchr(i8* %4, i8 signext 47)
%8 = icmp eq i8* %7, null
br i1 %8, label %14, label %9
9: ; preds = %2, %9
%10 = phi i8* [ %12, %9 ], [ %7, %2 ]
store i8 0, i8* %10
%11 = call i32 @add_one_size(i8* %4, i64 %1)
%12 = call i8* @strrchr(i8* %4, i8 signext 47)
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %9
14: ; preds = %9, %2
ret void
}