#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*/ strcpy(char *, char *);
size_t strlen(char *);
void addintlen(char *form) {
  size_t l = strlen(form);
  char spec = form[l - 1];
  strcpy(form + l - 1, "l");
  form[l + sizeof("l") - 2] = spec;
  form[l + sizeof("l") - 1] = '\0';
}


x86 assembly (clang, -O0):
<addintlen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    $0x1,%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x11(%rbp)
mov    -0x8(%rbp),%rdi
add    -0x10(%rbp),%rdi
add    $0xffffffffffffffff,%rdi
lea    0xea2(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x11(%rbp),%dl
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
add    $0x2,%rcx
sub    $0x2,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
add    $0x2,%rcx
sub    $0x1,%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<addintlen>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
call   1040 <strlen@plt>
mov    %rax,%r14
mov    -0x1(%rbx,%rax,1),%bpl
lea    (%rbx,%rax,1),%rdi
add    $0xffffffffffffffff,%rdi
lea    0xebd(%rip),%rsi
call   1030 <strcpy@plt>
mov    %bpl,(%rbx,%r14,1)
movb   $0x0,0x1(%rbx,%r14,1)
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"l\00"
define void @addintlen(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i8
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i64 @strlen(i8* %5)
store i64 %6, i64* %3
%7 = load i8*, i8** %2
%8 = load i64, i64* %3
%9 = sub i64 %8, 1
%10 = getelementptr inbounds i8, i8* %7, i64 %9
%11 = load i8, i8* %10
store i8 %11, i8* %4
%12 = load i8*, i8** %2
%13 = load i64, i64* %3
%14 = getelementptr inbounds i8, i8* %12, i64 %13
%15 = getelementptr inbounds i8, i8* %14, i64 -1
%16 = call i32 @strcpy(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%17 = load i8, i8* %4
%18 = load i8*, i8** %2
%19 = load i64, i64* %3
%20 = add i64 %19, 2
%21 = sub i64 %20, 2
%22 = getelementptr inbounds i8, i8* %18, i64 %21
store i8 %17, i8* %22
%23 = load i8*, i8** %2
%24 = load i64, i64* %3
%25 = add i64 %24, 2
%26 = sub i64 %25, 1
%27 = getelementptr inbounds i8, i8* %23, i64 %26
store i8 0, i8* %27
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"l\00"
define void @addintlen(i8* %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%3 = add i64 %2, -1
%4 = getelementptr inbounds i8, i8* %0, i64 %3
%5 = load i8, i8* %4
%6 = getelementptr inbounds i8, i8* %0, i64 %2
%7 = getelementptr inbounds i8, i8* %6, i64 -1
%8 = tail call i32 @strcpy(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8 %5, i8* %6
%9 = add i64 %2, 1
%10 = getelementptr inbounds i8, i8* %0, i64 %9
store i8 0, i8* %10
ret void
}