#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*/ PATH_MAX;
int /*<<< orphan*/ snprintf(char *, int /*<<< orphan*/, char *, ...);
void ft_mkname(char *name, char *dirname, int me, int idx) {
  char a, b;
  a = 'A' + (me % 26);
  b = 'a' + (idx % 26);
  if (dirname[0] != '\0')
    snprintf(name, PATH_MAX, "%s/%c%c", dirname, a, b);
  else
    snprintf(name, PATH_MAX, "%c%c", a, b);
}


x86 assembly (clang, -O0):
<ft_mkname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x1a,%ecx
cltd
idiv   %ecx
add    $0x41,%edx
mov    %dl,%al
mov    %al,-0x19(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x1a,%ecx
cltd
idiv   %ecx
add    $0x61,%edx
mov    %dl,%al
mov    %al,-0x1a(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     118a <ft_mkname+0x7a>
mov    -0x8(%rbp),%rdi
mov    0x2e89(%rip),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rcx
movsbl -0x19(%rbp),%r8d
movsbl -0x1a(%rbp),%r9d
lea    0xe82(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
jmp    11ae <ft_mkname+0x9e>
mov    -0x8(%rbp),%rdi
mov    0x2e5b(%rip),%rax
mov    (%rax),%esi
movsbl -0x19(%rbp),%ecx
movsbl -0x1a(%rbp),%r8d
lea    0xe5c(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_mkname>:
mov    %rsi,%r10
movslq %edx,%rdx
imul   $0x4ec4ec4f,%rdx,%rsi
mov    %rsi,%rax
shr    $0x3f,%rax
sar    $0x23,%rsi
add    %eax,%esi
lea    (%rsi,%rsi,4),%eax
lea    (%rax,%rax,4),%eax
add    %esi,%eax
neg    %eax
add    %edx,%eax
add    $0x41,%eax
movslq %ecx,%rcx
imul   $0x4ec4ec4f,%rcx,%rdx
mov    %rdx,%rsi
shr    $0x3f,%rsi
sar    $0x23,%rdx
add    %esi,%edx
lea    (%rdx,%rdx,4),%esi
lea    (%rsi,%rsi,4),%esi
add    %edx,%esi
neg    %esi
add    %esi,%ecx
add    $0x61,%ecx
cmpb   $0x0,(%r10)
mov    0x2e86(%rip),%rdx
mov    (%rdx),%esi
movzbl %al,%r8d
movzbl %cl,%r9d
je     1187 <ft_mkname+0x77>
lea    0xe83(%rip),%rdx
mov    %r10,%rcx
xor    %eax,%eax
jmp    1030 <snprintf@plt>
lea    0xe75(%rip),%rdx
mov    %r8d,%ecx
mov    %r9d,%r8d
xor    %eax,%eax
jmp    1030 <snprintf@plt>

LLVM IR (-O0):
@PATH_MAX = global i32 0
@.str = [8 x i8] c"%s/%c%c\00"
@.str.1 = [5 x i8] c"%c%c\00"
define void @ft_mkname(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8
%10 = alloca i8
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%11 = load i32, i32* %7
%12 = srem i32 %11, 26
%13 = add nsw i32 65, %12
%14 = trunc i32 %13 to i8
store i8 %14, i8* %9
%15 = load i32, i32* %8
%16 = srem i32 %15, 26
%17 = add nsw i32 97, %16
%18 = trunc i32 %17 to i8
store i8 %18, i8* %10
%19 = load i8*, i8** %6
%20 = getelementptr inbounds i8, i8* %19, i64 0
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %33
24: ; preds = %4
%25 = load i8*, i8** %5
%26 = load i32, i32* @PATH_MAX
%27 = load i8*, i8** %6
%28 = load i8, i8* %9
%29 = sext i8 %28 to i32
%30 = load i8, i8* %10
%31 = sext i8 %30 to i32
%32 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %25, i32 %26, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %27, i32 %29, i32 %31)
br label %41
33: ; preds = %4
%34 = load i8*, i8** %5
%35 = load i32, i32* @PATH_MAX
%36 = load i8, i8* %9
%37 = sext i8 %36 to i32
%38 = load i8, i8* %10
%39 = sext i8 %38 to i32
%40 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %34, i32 %35, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %37, i32 %39)
br label %41
41: ; preds = %33, %24
ret void
}

LLVM IR (-O2):
@PATH_MAX = global i32 0
@.str = [8 x i8] c"%s/%c%c\00"
@.str.1 = [5 x i8] c"%c%c\00"
define void @ft_mkname(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = srem i32 %2, 26
%6 = add nsw i32 %5, 65
%7 = srem i32 %3, 26
%8 = add nsw i32 %7, 97
%9 = load i8, i8* %1
%10 = icmp eq i8 %9, 0
%11 = load i32, i32* @PATH_MAX
%12 = and i32 %6, 255
%13 = and i32 %8, 255
br i1 %10, label %16, label %14
14: ; preds = %4
%15 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %0, i32 %11, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %1, i32 %12, i32 %13)
br label %18
16: ; preds = %4
%17 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %0, i32 %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %12, i32 %13)
br label %18
18: ; preds = %16, %14
ret void
}