#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 strlen(char const *);
char *GetUser(const char *line) {
  static char username[25];
  int len = strlen(line);
  int i;
  for (i = 0; i < len; i++) {
    if (line[i] == ':')
      break;
    username[i] = line[i];
  }
  username[i] = '\0';
  return (username);
}


x86 assembly (clang, -O0):
<GetUser>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    117c <GetUser+0x6c>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3a,%eax
jne    1155 <GetUser+0x45>
jmp    117c <GetUser+0x6c>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
movslq -0x10(%rbp),%rcx
lea    0x2ed5(%rip),%rax
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    112f <GetUser+0x1f>
movslq -0x10(%rbp),%rcx
lea    0x2eb9(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
lea    0x2eae(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetUser>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
test   %eax,%eax
jle    1149 <GetUser+0x39>
mov    %eax,%ecx
xor    %eax,%eax
lea    0x2f18(%rip),%rsi
nopl   0x0(%rax,%rax,1)
movzbl (%rbx,%rax,1),%edx
cmp    $0x3a,%dl
je     114b <GetUser+0x3b>
mov    %dl,(%rax,%rsi,1)
add    $0x1,%rax
cmp    %rax,%rcx
jne    1130 <GetUser+0x20>
mov    %ecx,%eax
jmp    114b <GetUser+0x3b>
xor    %eax,%eax
mov    %eax,%ecx
lea    0x2eec(%rip),%rax
movb   $0x0,(%rcx,%rax,1)
pop    %rbx
ret

LLVM IR (-O0):
@GetUser.username = internal global [25 x i8] zeroinitializer
define i8* @GetUser(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i32 @strlen(i8* %5)
store i32 %6, i32* %3
store i32 0, i32* %4
br label %7
7: ; preds = %29, %1
%8 = load i32, i32* %4
%9 = load i32, i32* %3
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %32
11: ; preds = %7
%12 = load i8*, i8** %2
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 58
br i1 %18, label %19, label %20
19: ; preds = %11
br label %32
20: ; preds = %11
%21 = load i8*, i8** %2
%22 = load i32, i32* %4
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = load i8, i8* %24
%26 = load i32, i32* %4
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [25 x i8], [25 x i8]* @GetUser.username, i64 0, i64 %27
store i8 %25, i8* %28
br label %29
29: ; preds = %20
%30 = load i32, i32* %4
%31 = add nsw i32 %30, 1
store i32 %31, i32* %4
br label %7
32: ; preds = %19, %7
%33 = load i32, i32* %4
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [25 x i8], [25 x i8]* @GetUser.username, i64 0, i64 %34
store i8 0, i8* %35
ret i8* getelementptr inbounds ([25 x i8], [25 x i8]* @GetUser.username, i64 0, i64 0)
}

LLVM IR (-O2):
@GetUser.username = internal global [25 x i8] zeroinitializer
define i8* @GetUser(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp sgt i32 %2, 0
br i1 %3, label %4, label %17
4: ; preds = %1
%5 = zext i32 %2 to i64
br label %6
6: ; preds = %4, %11
%7 = phi i64 [ 0, %4 ], [ %13, %11 ]
%8 = getelementptr inbounds i8, i8* %0, i64 %7
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 58
br i1 %10, label %15, label %11
11: ; preds = %6
%12 = getelementptr inbounds [25 x i8], [25 x i8]* @GetUser.username, i64 0, i64 %7
store i8 %9, i8* %12
%13 = add nuw nsw i64 %7, 1
%14 = icmp eq i64 %13, %5
br i1 %14, label %17, label %6
15: ; preds = %6
%16 = trunc i64 %7 to i32
br label %17
17: ; preds = %11, %15, %1
%18 = phi i32 [ 0, %1 ], [ %16, %15 ], [ %2, %11 ]
%19 = zext i32 %18 to i64
%20 = getelementptr inbounds [25 x i8], [25 x i8]* @GetUser.username, i64 0, i64 %19
store i8 0, i8* %20
ret i8* getelementptr inbounds ([25 x i8], [25 x i8]* @GetUser.username, i64 0, i64 0)
}