#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*/ sprintf(char *, char *, char *, ...);
void build_sys_string(char *sys_string, char *subject, char **address_list) {
  char *ptr = sys_string;
  ptr += sprintf(ptr, "mail -s \"%s\" %s", subject, *address_list++);
  while (*address_list)
    ptr += sprintf(ptr, " %s", *address_list++);
}


x86 assembly (clang, -O0):
<build_sys_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x18(%rbp)
mov    (%rax),%rcx
lea    0xeb3(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
je     11ab <build_sys_string+0x9b>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x18(%rbp)
mov    (%rax),%rdx
lea    0xe7d(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
jmp    1164 <build_sys_string+0x54>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<build_sys_string>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%rdx
mov    %rdi,%rbx
mov    (%r14),%rcx
lea    0xed8(%rip),%rsi
xor    %eax,%eax
call   1030 <sprintf@plt>
mov    0x8(%r14),%rdx
test   %rdx,%rdx
je     116e <build_sys_string+0x5e>
cltq
add    %rax,%rbx
add    $0x10,%r14
lea    0xec4(%rip),%r15
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1030 <sprintf@plt>
cltq
add    %rax,%rbx
mov    (%r14),%rdx
add    $0x8,%r14
test   %rdx,%rdx
jne    1150 <build_sys_string+0x40>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [16 x i8] c"mail -s \22%s\22 %s\00"
@.str.1 = [4 x i8] c" %s\00"
define void @build_sys_string(i8* %0, i8* %1, i8** %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8**
%7 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8** %2, i8*** %6
%8 = load i8*, i8** %4
store i8* %8, i8** %7
%9 = load i8*, i8** %7
%10 = load i8*, i8** %5
%11 = load i8**, i8*** %6
%12 = getelementptr inbounds i8*, i8** %11, i32 1
store i8** %12, i8*** %6
%13 = load i8*, i8** %11
%14 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %9, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %10, i8* %13)
%15 = load i8*, i8** %7
%16 = sext i32 %14 to i64
%17 = getelementptr inbounds i8, i8* %15, i64 %16
store i8* %17, i8** %7
br label %18
18: ; preds = %22, %3
%19 = load i8**, i8*** %6
%20 = load i8*, i8** %19
%21 = icmp ne i8* %20, null
br i1 %21, label %22, label %31
22: ; preds = %18
%23 = load i8*, i8** %7
%24 = load i8**, i8*** %6
%25 = getelementptr inbounds i8*, i8** %24, i32 1
store i8** %25, i8*** %6
%26 = load i8*, i8** %24
%27 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %23, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %26)
%28 = load i8*, i8** %7
%29 = sext i32 %27 to i64
%30 = getelementptr inbounds i8, i8* %28, i64 %29
store i8* %30, i8** %7
br label %18
31: ; preds = %18
ret void
}

LLVM IR (-O2):
@.str = [16 x i8] c"mail -s \22%s\22 %s\00"
@.str.1 = [4 x i8] c" %s\00"
define void @build_sys_string(i8* nocapture writeonly %0, i8* %1, i8** nocapture %2) {
%4 = load i8*, i8** %2
%5 = tail call i32 (i8*, i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %4)
%6 = getelementptr inbounds i8*, i8** %2, i64 1
%7 = load i8*, i8** %6
%8 = icmp eq i8* %7, null
br i1 %8, label %22, label %9
9: ; preds = %3
%10 = sext i32 %5 to i64
%11 = getelementptr inbounds i8, i8* %0, i64 %10
br label %12
12: ; preds = %9, %12
%13 = phi i8* [ %20, %12 ], [ %7, %9 ]
%14 = phi i8** [ %19, %12 ], [ %6, %9 ]
%15 = phi i8* [ %18, %12 ], [ %11, %9 ]
%16 = tail call i32 (i8*, i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %15, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = getelementptr inbounds i8*, i8** %14, i64 1
%20 = load i8*, i8** %19
%21 = icmp eq i8* %20, null
br i1 %21, label %22, label %12
22: ; preds = %12, %3
ret void
}