#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 */
struct session {
  int dummy;
};
struct listnode {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ do_internal_variable(struct session *, char *);
char *get_arg_in_braces(char *, char *, int /*<<< orphan*/);
int get_list_length(struct listnode *);
int /*<<< orphan*/ sprintf(char *, char *, char *, int);
struct session *array_len(struct session *ses, struct listnode *list,
                          char *arg) {
  char left[10000], buf[10000];
  arg = get_arg_in_braces(arg, left, 0);
  sprintf(buf, "{%s} {%d}", left, get_list_length(list));
  do_internal_variable(ses, buf);
  return ses;
}


x86 assembly (clang, -O0):
<array_len>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4e50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x2730(%rbp),%rsi
xor    %edx,%edx
call   1030 <get_arg_in_braces@plt>
mov    %rax,-0x18(%rbp)
lea    -0x4e40(%rbp),%rax
mov    %rax,-0x4e50(%rbp)
lea    -0x2730(%rbp),%rax
mov    %rax,-0x4e48(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <get_list_length@plt>
mov    -0x4e50(%rbp),%rdi
mov    -0x4e48(%rbp),%rdx
mov    %eax,%ecx
lea    0xe57(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x4e40(%rbp),%rsi
call   1060 <do_internal_variable@plt>
mov    -0x8(%rbp),%rax
add    $0x4e50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<array_len>:
push   %r15
push   %r14
push   %rbx
sub    $0x4e20,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0x2710(%rsp),%r15
mov    %rdx,%rdi
mov    %r15,%rsi
xor    %edx,%edx
call   1030 <get_arg_in_braces@plt>
mov    %r14,%rdi
call   1040 <get_list_length@plt>
lea    0xe8a(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
mov    %r15,%rdx
mov    %eax,%ecx
call   1050 <sprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <do_internal_variable@plt>
mov    %rbx,%rax
add    $0x4e20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.session = type { i32 }
%struct.listnode = type { i32 }
@.str = [10 x i8] c"{%s} {%d}\00"
define %struct.session* @array_len(%struct.session* %0, %struct.listnode* %1, i8* %2) {
%4 = alloca %struct.session*
%5 = alloca %struct.listnode*
%6 = alloca i8*
%7 = alloca [10000 x i8]
%8 = alloca [10000 x i8]
store %struct.session* %0, %struct.session** %4
store %struct.listnode* %1, %struct.listnode** %5
store i8* %2, i8** %6
%9 = load i8*, i8** %6
%10 = getelementptr inbounds [10000 x i8], [10000 x i8]* %7, i64 0, i64 0
%11 = call i8* @get_arg_in_braces(i8* %9, i8* %10, i32 0)
store i8* %11, i8** %6
%12 = getelementptr inbounds [10000 x i8], [10000 x i8]* %8, i64 0, i64 0
%13 = getelementptr inbounds [10000 x i8], [10000 x i8]* %7, i64 0, i64 0
%14 = load %struct.listnode*, %struct.listnode** %5
%15 = call i32 @get_list_length(%struct.listnode* %14)
%16 = call i32 @sprintf(i8* %12, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %13, i32 %15)
%17 = load %struct.session*, %struct.session** %4
%18 = getelementptr inbounds [10000 x i8], [10000 x i8]* %8, i64 0, i64 0
%19 = call i32 @do_internal_variable(%struct.session* %17, i8* %18)
%20 = load %struct.session*, %struct.session** %4
ret %struct.session* %20
}

LLVM IR (-O2):
%struct.session = type { i32 }
%struct.listnode = type { i32 }
@.str = [10 x i8] c"{%s} {%d}\00"
define %struct.session* @array_len(%struct.session* returned %0, %struct.listnode* %1, i8* %2) {
%4 = alloca [10000 x i8]
%5 = alloca [10000 x i8]
%6 = getelementptr inbounds [10000 x i8], [10000 x i8]* %4, i64 0, i64 0
%7 = getelementptr inbounds [10000 x i8], [10000 x i8]* %5, i64 0, i64 0
%8 = call i8* @get_arg_in_braces(i8* %2, i8* %6, i32 0)
%9 = call i32 @get_list_length(%struct.listnode* %1)
%10 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %6, i32 %9)
%11 = call i32 @do_internal_variable(%struct.session* %0, i8* %7)
ret %struct.session* %0
}