#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*/ sprintf(char *, char *, int);
char *strdup(char *);
char *get_simple_uid(char *uname) {
  int id = 0;
  char *aux;
  for (aux = uname; *aux; aux++) {
    id = id + (int)*aux;
  }
  char strId[25];
  sprintf(strId, "%d", id);
  return strdup(strId);
}


x86 assembly (clang, -O0):
<get_simple_uid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     1168 <get_simple_uid+0x48>
mov    -0xc(%rbp),%eax
mov    -0x18(%rbp),%rcx
movsbl (%rcx),%ecx
add    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    113b <get_simple_uid+0x1b>
lea    -0x40(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xe8a(%rip),%rsi
call   1030 <sprintf@plt>
lea    -0x40(%rbp),%rdi
call   1040 <strdup@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_simple_uid>:
push   %rbx
sub    $0x20,%rsp
mov    (%rdi),%al
test   %al,%al
je     1152 <get_simple_uid+0x32>
add    $0x1,%rdi
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl %al,%eax
add    %eax,%edx
movzbl (%rdi),%eax
add    $0x1,%rdi
test   %al,%al
jne    1140 <get_simple_uid+0x20>
jmp    1154 <get_simple_uid+0x34>
xor    %edx,%edx
lea    0xea5(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <strdup@plt>
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define i8* @get_simple_uid(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
%5 = alloca [25 x i8]
store i8* %0, i8** %2
store i32 0, i32* %3
%6 = load i8*, i8** %2
store i8* %6, i8** %4
br label %7
7: ; preds = %17, %1
%8 = load i8*, i8** %4
%9 = load i8, i8* %8
%10 = icmp ne i8 %9, 0
br i1 %10, label %11, label %20
11: ; preds = %7
%12 = load i32, i32* %3
%13 = load i8*, i8** %4
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = add nsw i32 %12, %15
store i32 %16, i32* %3
br label %17
17: ; preds = %11
%18 = load i8*, i8** %4
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** %4
br label %7
20: ; preds = %7
%21 = getelementptr inbounds [25 x i8], [25 x i8]* %5, i64 0, i64 0
%22 = load i32, i32* %3
%23 = call i32 @sprintf(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %22)
%24 = getelementptr inbounds [25 x i8], [25 x i8]* %5, i64 0, i64 0
%25 = call i8* @strdup(i8* %24)
ret i8* %25
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define noalias i8* @get_simple_uid(i8* nocapture %0) {
%2 = alloca [25 x i8]
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %14, label %5
5: ; preds = %1, %5
%6 = phi i8 [ %12, %5 ], [ %3, %1 ]
%7 = phi i8* [ %11, %5 ], [ %0, %1 ]
%8 = phi i32 [ %10, %5 ], [ 0, %1 ]
%9 = sext i8 %6 to i32
%10 = add nsw i32 %8, %9
%11 = getelementptr inbounds i8, i8* %7, i64 1
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 0
br i1 %13, label %14, label %5
14: ; preds = %5, %1
%15 = phi i32 [ 0, %1 ], [ %10, %5 ]
%16 = getelementptr inbounds [25 x i8], [25 x i8]* %2, i64 0, i64 0
%17 = call i32 @sprintf(i8* %16, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %15)
%18 = call i8* @strdup(i8* %16)
ret i8* %18
}