#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*/ log_message(char *, char *, char *, int);
char *malloc(int);
int rand();
char *generate_search_id(void) {
  char *id = malloc(9);
  int i;
  if (!id) {
    log_message("%s: OUT OF MEMORY at %s:%d", "generate_search_id",
                "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/OS2World/APP-SERVER-opennap/"
                "refs/heads/master/search.c",
                89);
    return 0;
  }
  for (i = 0; i < 8; i++)
    id[i] = 'A' + (rand() % 26);
  id[8] = 0;
  return id;
}


x86 assembly (clang, -O0):
<generate_search_id>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x9,%edi
call   1030 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    117d <generate_search_id+0x4d>
lea    0xea8(%rip),%rdi
lea    0xebc(%rip),%rsi
lea    0xec8(%rip),%rdx
mov    $0x59,%ecx
call   1040 <log_message@plt>
movq   $0x0,-0x8(%rbp)
jmp    11c9 <generate_search_id+0x99>
movl   $0x0,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
jge    11b9 <generate_search_id+0x89>
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x1a,%ecx
cltd
idiv   %ecx
add    $0x41,%edx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1184 <generate_search_id+0x54>
mov    -0x10(%rbp),%rax
movb   $0x0,0x8(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate_search_id>:
push   %rbx
mov    $0x9,%edi
call   1030 <malloc@plt>
mov    %rax,%rbx
test   %rax,%rax
je     12ac <generate_search_id+0x17c>
xor    %eax,%eax
call   1050 <rand@plt>
cltq
imul   $0x4ec4ec4f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x23,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
sub    %edx,%eax
add    $0x41,%al
mov    %al,(%rbx)
xor    %eax,%eax
call   1050 <rand@plt>
cltq
imul   $0x4ec4ec4f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x23,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
sub    %edx,%eax
add    $0x41,%al
mov    %al,0x1(%rbx)
xor    %eax,%eax
call   1050 <rand@plt>
cltq
imul   $0x4ec4ec4f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x23,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
sub    %edx,%eax
add    $0x41,%al
mov    %al,0x2(%rbx)
xor    %eax,%eax
call   1050 <rand@plt>
cltq
imul   $0x4ec4ec4f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x23,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
sub    %edx,%eax
add    $0x41,%al
mov    %al,0x3(%rbx)
xor    %eax,%eax
call   1050 <rand@plt>
cltq
imul   $0x4ec4ec4f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x23,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
sub    %edx,%eax
add    $0x41,%al
mov    %al,0x4(%rbx)
xor    %eax,%eax
call   1050 <rand@plt>
cltq
imul   $0x4ec4ec4f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x23,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
sub    %edx,%eax
add    $0x41,%al
mov    %al,0x5(%rbx)
xor    %eax,%eax
call   1050 <rand@plt>
cltq
imul   $0x4ec4ec4f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x23,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
sub    %edx,%eax
add    $0x41,%al
mov    %al,0x6(%rbx)
xor    %eax,%eax
call   1050 <rand@plt>
cltq
imul   $0x4ec4ec4f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x23,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
sub    %edx,%eax
add    $0x41,%al
mov    %al,0x7(%rbx)
movb   $0x0,0x8(%rbx)
jmp    12cb <generate_search_id+0x19b>
lea    0xd4d(%rip),%rdi
lea    0xd61(%rip),%rsi
lea    0xd6d(%rip),%rdx
mov    $0x59,%ecx
call   1040 <log_message@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [27 x i8] c"%s: OUT OF MEMORY at %s:%d\00"
@.str.1 = [19 x i8] c"generate_search_id\00"
@.str.2 = [145 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/OS2World/APP-SERVER-opennap/refs/heads/master/search.c\00"
define i8* @generate_search_id() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca i32
%4 = call i8* @malloc(i32 9)
store i8* %4, i8** %2
%5 = load i8*, i8** %2
%6 = icmp ne i8* %5, null
br i1 %6, label %9, label %7
7: ; preds = %0
%8 = call i32 @log_message(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([145 x i8], [145 x i8]* @.str.2, i64 0, i64 0), i32 89)
store i8* null, i8** %1
br label %29
9: ; preds = %0
store i32 0, i32* %3
br label %10
10: ; preds = %22, %9
%11 = load i32, i32* %3
%12 = icmp slt i32 %11, 8
br i1 %12, label %13, label %25
13: ; preds = %10
%14 = call i32 (...) @rand()
%15 = srem i32 %14, 26
%16 = add nsw i32 65, %15
%17 = trunc i32 %16 to i8
%18 = load i8*, i8** %2
%19 = load i32, i32* %3
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
store i8 %17, i8* %21
br label %22
22: ; preds = %13
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
store i32 %24, i32* %3
br label %10
25: ; preds = %10
%26 = load i8*, i8** %2
%27 = getelementptr inbounds i8, i8* %26, i64 8
store i8 0, i8* %27
%28 = load i8*, i8** %2
store i8* %28, i8** %1
br label %29
29: ; preds = %25, %7
%30 = load i8*, i8** %1
ret i8* %30
}

LLVM IR (-O2):
@.str = [27 x i8] c"%s: OUT OF MEMORY at %s:%d\00"
@.str.1 = [19 x i8] c"generate_search_id\00"
@.str.2 = [145 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/OS2World/APP-SERVER-opennap/refs/heads/master/search.c\00"
define noalias i8* @generate_search_id() {
%1 = tail call dereferenceable_or_null(9) i8* @malloc(i32 9)
%2 = icmp eq i8* %1, null
br i1 %2, label %44, label %3
3: ; preds = %0
%4 = tail call i32 (...) @rand()
%5 = srem i32 %4, 26
%6 = trunc i32 %5 to i8
%7 = add nsw i8 %6, 65
store i8 %7, i8* %1
%8 = tail call i32 (...) @rand()
%9 = srem i32 %8, 26
%10 = trunc i32 %9 to i8
%11 = add nsw i8 %10, 65
%12 = getelementptr inbounds i8, i8* %1, i64 1
store i8 %11, i8* %12
%13 = tail call i32 (...) @rand()
%14 = srem i32 %13, 26
%15 = trunc i32 %14 to i8
%16 = add nsw i8 %15, 65
%17 = getelementptr inbounds i8, i8* %1, i64 2
store i8 %16, i8* %17
%18 = tail call i32 (...) @rand()
%19 = srem i32 %18, 26
%20 = trunc i32 %19 to i8
%21 = add nsw i8 %20, 65
%22 = getelementptr inbounds i8, i8* %1, i64 3
store i8 %21, i8* %22
%23 = tail call i32 (...) @rand()
%24 = srem i32 %23, 26
%25 = trunc i32 %24 to i8
%26 = add nsw i8 %25, 65
%27 = getelementptr inbounds i8, i8* %1, i64 4
store i8 %26, i8* %27
%28 = tail call i32 (...) @rand()
%29 = srem i32 %28, 26
%30 = trunc i32 %29 to i8
%31 = add nsw i8 %30, 65
%32 = getelementptr inbounds i8, i8* %1, i64 5
store i8 %31, i8* %32
%33 = tail call i32 (...) @rand()
%34 = srem i32 %33, 26
%35 = trunc i32 %34 to i8
%36 = add nsw i8 %35, 65
%37 = getelementptr inbounds i8, i8* %1, i64 6
store i8 %36, i8* %37
%38 = tail call i32 (...) @rand()
%39 = srem i32 %38, 26
%40 = trunc i32 %39 to i8
%41 = add nsw i8 %40, 65
%42 = getelementptr inbounds i8, i8* %1, i64 7
store i8 %41, i8* %42
%43 = getelementptr inbounds i8, i8* %1, i64 8
store i8 0, i8* %43
br label %46
44: ; preds = %0
%45 = tail call i32 @log_message(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([145 x i8], [145 x i8]* @.str.2, i64 0, i64 0), i32 89)
br label %46
46: ; preds = %3, %44
ret i8* %1
}