#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 outbuff {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ outmemcpy(struct outbuff *, char const *, int);
int /*<<< orphan*/ outmemset(struct outbuff *, char, int);
int strlen(char const *);
void outstr(struct outbuff *out, const char *s, unsigned flags) {
  int slen = strlen(s);
  int len = flags & 0x0fffff;
  int pad = len - slen;
  if ((flags & 0x100000) == 0) {
    outmemset(out, ' ', pad);
    pad = 0;
  }
  outmemcpy(out, s, slen);
  outmemset(out, ' ', pad);
}


x86 assembly (clang, -O0):
<outstr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
and    $0xfffff,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
sub    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
and    $0x100000,%eax
cmp    $0x0,%eax
jne    118c <outstr+0x5c>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%edx
mov    $0x20,%esi
call   1050 <outmemset@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%edx
call   1030 <outmemcpy@plt>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%edx
mov    $0x20,%esi
call   1050 <outmemset@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<outstr>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%ebx
mov    %rsi,%r14
mov    %rdi,%r15
mov    %rsi,%rdi
call   1040 <strlen@plt>
mov    %eax,%r12d
mov    %ebx,%ebp
and    $0xfffff,%ebp
sub    %eax,%ebp
test   $0x100000,%ebx
jne    116e <outstr+0x3e>
mov    %r15,%rdi
mov    $0x20,%esi
mov    %ebp,%edx
call   1050 <outmemset@plt>
xor    %ebp,%ebp
mov    %r15,%rdi
mov    %r14,%rsi
mov    %r12d,%edx
call   1030 <outmemcpy@plt>
mov    %r15,%rdi
mov    $0x20,%esi
mov    %ebp,%edx
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <outmemset@plt>

LLVM IR (-O0):
%struct.outbuff = type { i32 }
define void @outstr(%struct.outbuff* %0, i8* %1, i32 %2) {
%4 = alloca %struct.outbuff*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store %struct.outbuff* %0, %struct.outbuff** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%10 = load i8*, i8** %5
%11 = call i32 @strlen(i8* %10)
store i32 %11, i32* %7
%12 = load i32, i32* %6
%13 = and i32 %12, 1048575
store i32 %13, i32* %8
%14 = load i32, i32* %8
%15 = load i32, i32* %7
%16 = sub nsw i32 %14, %15
store i32 %16, i32* %9
%17 = load i32, i32* %6
%18 = and i32 %17, 1048576
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %3
%21 = load %struct.outbuff*, %struct.outbuff** %4
%22 = load i32, i32* %9
%23 = call i32 @outmemset(%struct.outbuff* %21, i8 signext 32, i32 %22)
store i32 0, i32* %9
br label %24
24: ; preds = %20, %3
%25 = load %struct.outbuff*, %struct.outbuff** %4
%26 = load i8*, i8** %5
%27 = load i32, i32* %7
%28 = call i32 @outmemcpy(%struct.outbuff* %25, i8* %26, i32 %27)
%29 = load %struct.outbuff*, %struct.outbuff** %4
%30 = load i32, i32* %9
%31 = call i32 @outmemset(%struct.outbuff* %29, i8 signext 32, i32 %30)
ret void
}

LLVM IR (-O2):
%struct.outbuff = type { i32 }
define void @outstr(%struct.outbuff* %0, i8* %1, i32 %2) {
%4 = tail call i32 @strlen(i8* %1)
%5 = and i32 %2, 1048575
%6 = sub nsw i32 %5, %4
%7 = and i32 %2, 1048576
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %3
%10 = tail call i32 @outmemset(%struct.outbuff* %0, i8 signext 32, i32 %6)
br label %11
11: ; preds = %9, %3
%12 = phi i32 [ 0, %9 ], [ %6, %3 ]
%13 = tail call i32 @outmemcpy(%struct.outbuff* %0, i8* %1, i32 %4)
%14 = tail call i32 @outmemset(%struct.outbuff* %0, i8 signext 32, i32 %12)
ret void
}