#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 outnum(struct outbuff *out, const char *s, unsigned flags) {
  int slen = strlen(s);
  int len = flags & 0x0fffff;
  if (len)
    outmemset(out, (flags & 0x200000) ? '0' : ' ', len - slen);
  outmemcpy(out, s, slen);
}


x86 assembly (clang, -O0):
<outnum>:
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)
cmpl   $0x0,-0x1c(%rbp)
je     118f <outnum+0x5f>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%edx
and    $0x200000,%edx
mov    $0x20,%eax
mov    $0x30,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    -0x1c(%rbp),%edx
sub    -0x18(%rbp),%edx
movsbl %al,%esi
call   1050 <outmemset@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%edx
call   1030 <outmemcpy@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<outnum>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1040 <strlen@plt>
mov    %eax,%r15d
mov    %ebp,%edx
and    $0xfffff,%edx
je     116a <outnum+0x3a>
sub    %r15d,%edx
shr    $0x11,%ebp
and    $0x10,%ebp
or     $0x20,%ebp
mov    %r14,%rdi
mov    %ebp,%esi
call   1050 <outmemset@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r15d,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <outmemcpy@plt>

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

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