#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 *, ...);
int do_action(char *donesp, char *actsp, char *ressp) {
  int ret;
  char *mysp;
  mysp = donesp;
  donesp += sprintf(donesp, "<H1>Action Sent</H1>\n");
  donesp += sprintf(donesp, "<table border=1><tr><td><pre>\n");
  donesp += sprintf(donesp, "%s", actsp);
  donesp += sprintf(donesp, "</pre></td></tr></table>\n");
  donesp += sprintf(donesp, "<H1>Action Result</H1>\n");
  donesp += sprintf(donesp, "<pre>\n");
  donesp += sprintf(donesp, "%s", ressp);
  donesp += sprintf(donesp, "</pre></td></tr></table>\n");
  ret = donesp - mysp;
  return ret;
}


x86 assembly (clang, -O0):
<do_action>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xec9(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xebd(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xeb6(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe97(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe8f(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe49(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe2a(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe0b(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x28(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_action>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rdi,%rbx
movups 0xedb(%rip),%xmm0
movups %xmm0,(%rdi)
movabs $0xa3e31482f3c74,%rax
mov    %rax,0xe(%rdi)
movups 0xed9(%rip),%xmm0
movups %xmm0,0x15(%rdi)
movups 0xedd(%rip),%xmm0
movups %xmm0,0x24(%rdi)
lea    0x33(%rdi),%r15
mov    %r15,%rdi
call   1030 <stpcpy@plt>
sub    %r15d,%eax
cltq
lea    (%rbx,%rax,1),%r12
add    $0x33,%r12
movups 0xed2(%rip),%xmm0
movups %xmm0,0x3c(%rbx,%rax,1)
movups 0xebd(%rip),%xmm0
movups %xmm0,0x33(%rbx,%rax,1)
movabs $0xa3e31482f3c746c,%rcx
31 3e 0a
mov    %rcx,0x5b(%rbx,%rax,1)
movups 0xebc(%rip),%xmm0
movups %xmm0,0x4c(%rbx,%rax,1)
movl   $0xa3e65,0x66(%rbx,%rax,1)
movl   $0x6572703c,0x63(%rbx,%rax,1)
65
lea    (%rbx,%rax,1),%r15
add    $0x69,%r15
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <stpcpy@plt>
sub    %r15d,%eax
movslq %eax,%rcx
lea    (%rcx,%r12,1),%rax
add    $0x36,%rax
movups 0xe65(%rip),%xmm0
movups %xmm0,0x36(%rcx,%r12,1)
movups 0xe62(%rip),%xmm0
movups %xmm0,0x40(%rcx,%r12,1)
sub    %ebx,%eax
add    $0x19,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [22 x i8] c"<H1>Action Sent</H1>\0A\00"
@.str.1 = [31 x i8] c"<table border=1><tr><td><pre>\0A\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [26 x i8] c"</pre></td></tr></table>\0A\00"
@.str.4 = [24 x i8] c"<H1>Action Result</H1>\0A\00"
@.str.5 = [7 x i8] c"<pre>\0A\00"
define i32 @do_action(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%9 = load i8*, i8** %4
store i8* %9, i8** %8
%10 = load i8*, i8** %4
%11 = call i32 (i8*, i8*, ...) @sprintf(i8* %10, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%12 = load i8*, i8** %4
%13 = sext i32 %11 to i64
%14 = getelementptr inbounds i8, i8* %12, i64 %13
store i8* %14, i8** %4
%15 = load i8*, i8** %4
%16 = call i32 (i8*, i8*, ...) @sprintf(i8* %15, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%17 = load i8*, i8** %4
%18 = sext i32 %16 to i64
%19 = getelementptr inbounds i8, i8* %17, i64 %18
store i8* %19, i8** %4
%20 = load i8*, i8** %4
%21 = load i8*, i8** %5
%22 = call i32 (i8*, i8*, ...) @sprintf(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %21)
%23 = load i8*, i8** %4
%24 = sext i32 %22 to i64
%25 = getelementptr inbounds i8, i8* %23, i64 %24
store i8* %25, i8** %4
%26 = load i8*, i8** %4
%27 = call i32 (i8*, i8*, ...) @sprintf(i8* %26, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%28 = load i8*, i8** %4
%29 = sext i32 %27 to i64
%30 = getelementptr inbounds i8, i8* %28, i64 %29
store i8* %30, i8** %4
%31 = load i8*, i8** %4
%32 = call i32 (i8*, i8*, ...) @sprintf(i8* %31, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%33 = load i8*, i8** %4
%34 = sext i32 %32 to i64
%35 = getelementptr inbounds i8, i8* %33, i64 %34
store i8* %35, i8** %4
%36 = load i8*, i8** %4
%37 = call i32 (i8*, i8*, ...) @sprintf(i8* %36, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%38 = load i8*, i8** %4
%39 = sext i32 %37 to i64
%40 = getelementptr inbounds i8, i8* %38, i64 %39
store i8* %40, i8** %4
%41 = load i8*, i8** %4
%42 = load i8*, i8** %6
%43 = call i32 (i8*, i8*, ...) @sprintf(i8* %41, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %42)
%44 = load i8*, i8** %4
%45 = sext i32 %43 to i64
%46 = getelementptr inbounds i8, i8* %44, i64 %45
store i8* %46, i8** %4
%47 = load i8*, i8** %4
%48 = call i32 (i8*, i8*, ...) @sprintf(i8* %47, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%49 = load i8*, i8** %4
%50 = sext i32 %48 to i64
%51 = getelementptr inbounds i8, i8* %49, i64 %50
store i8* %51, i8** %4
%52 = load i8*, i8** %4
%53 = load i8*, i8** %8
%54 = ptrtoint i8* %52 to i64
%55 = ptrtoint i8* %53 to i64
%56 = sub i64 %54, %55
%57 = trunc i64 %56 to i32
store i32 %57, i32* %7
%58 = load i32, i32* %7
ret i32 %58
}

LLVM IR (-O2):
@.str = [22 x i8] c"<H1>Action Sent</H1>\0A\00"
@.str.1 = [31 x i8] c"<table border=1><tr><td><pre>\0A\00"
@.str.3 = [26 x i8] c"</pre></td></tr></table>\0A\00"
@.str.4 = [24 x i8] c"<H1>Action Result</H1>\0A\00"
@.str.5 = [7 x i8] c"<pre>\0A\00"
define i32 @do_action(i8* %0, i8* nocapture %1, i8* nocapture %2) {
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(22) %0, i8* align 1 dereferenceable(22) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i64 22, i1 false)
%4 = getelementptr inbounds i8, i8* %0, i64 21
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(31) %4, i8* align 1 dereferenceable(31) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i64 31, i1 false)
%5 = getelementptr inbounds i8, i8* %0, i64 51
%6 = tail call i8* @stpcpy(i8* %5, i8* %1)
%7 = ptrtoint i8* %6 to i64
%8 = ptrtoint i8* %5 to i64
%9 = sub i64 %7, %8
%10 = shl i64 %9, 32
%11 = ashr exact i64 %10, 32
%12 = getelementptr inbounds i8, i8* %5, i64 %11
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(26) %12, i8* align 1 dereferenceable(26) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i64 25, i1 false)
%13 = getelementptr inbounds i8, i8* %12, i64 25
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(24) %13, i8* align 1 dereferenceable(24) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i64 23, i1 false)
%14 = getelementptr inbounds i8, i8* %13, i64 23
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(7) %14, i8* align 1 dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i64 7, i1 false)
%15 = getelementptr inbounds i8, i8* %14, i64 6
%16 = tail call i8* @stpcpy(i8* %15, i8* %2)
%17 = ptrtoint i8* %16 to i64
%18 = ptrtoint i8* %15 to i64
%19 = sub i64 %17, %18
%20 = shl i64 %19, 32
%21 = ashr exact i64 %20, 32
%22 = getelementptr inbounds i8, i8* %15, i64 %21
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(26) %22, i8* align 1 dereferenceable(26) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i64 26, i1 false)
%23 = getelementptr inbounds i8, i8* %22, i64 25
%24 = ptrtoint i8* %23 to i64
%25 = ptrtoint i8* %0 to i64
%26 = sub i64 %24, %25
%27 = trunc i64 %26 to i32
ret i32 %27
}