#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*/ memset(char *, int, int);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int /*<<< orphan*/ strncat(char *, char *, int);
int /*<<< orphan*/ strncpy(char *, char *, int);
int padrightzeros(char *str_in, char *str_out) {
  char zerostr[7];
  int numstrsize = strlen(str_in);
  if (numstrsize > 7) {
    strncpy(str_out, str_in, 7);
  } else if (numstrsize == 7) {
    strncpy(str_out, str_in, 7);
  } else {
    strcpy(str_out, str_in);
    memset(zerostr, 0x30, 7 - strlen(str_in));
    strncat(str_out, zerostr, 7 - strlen(str_in));
  }
  return 0;
}


x86 assembly (clang, -O0):
<padrightzeros>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x7,-0x1c(%rbp)
jle    118d <padrightzeros+0x3d>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x7,%edx
call   1030 <strncpy@plt>
jmp    1213 <padrightzeros+0xc3>
cmpl   $0x7,-0x1c(%rbp)
jne    11ae <padrightzeros+0x5e>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x7,%edx
call   1030 <strncpy@plt>
jmp    120e <padrightzeros+0xbe>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x17(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x38(%rbp),%rdi
mov    $0x7,%edx
sub    %eax,%edx
mov    $0x30,%esi
call   1060 <memset@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
lea    -0x17(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    $0x7,%edx
sub    %eax,%edx
call   1070 <strncat@plt>
jmp    1213 <padrightzeros+0xc3>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<padrightzeros>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1050 <strlen@plt>
cmp    $0x8,%eax
jge    116c <padrightzeros+0x1c>
cmp    $0x7,%eax
jne    117e <padrightzeros+0x2e>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x7,%edx
call   1030 <strncpy@plt>
jmp    11c6 <padrightzeros+0x76>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    $0x7,%ebp
mov    $0x7,%edx
sub    %eax,%edx
lea    0x1(%rsp),%r15
mov    %r15,%rdi
mov    $0x30,%esi
call   1060 <memset@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
sub    %eax,%ebp
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
call   1070 <strncat@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @padrightzeros(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [7 x i8]
%6 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %3
%8 = call i32 @strlen(i8* %7)
store i32 %8, i32* %6
%9 = load i32, i32* %6
%10 = icmp sgt i32 %9, 7
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load i8*, i8** %4
%13 = load i8*, i8** %3
%14 = call i32 @strncpy(i8* %12, i8* %13, i32 7)
br label %38
15: ; preds = %2
%16 = load i32, i32* %6
%17 = icmp eq i32 %16, 7
br i1 %17, label %18, label %22
18: ; preds = %15
%19 = load i8*, i8** %4
%20 = load i8*, i8** %3
%21 = call i32 @strncpy(i8* %19, i8* %20, i32 7)
br label %37
22: ; preds = %15
%23 = load i8*, i8** %4
%24 = load i8*, i8** %3
%25 = call i32 @strcpy(i8* %23, i8* %24)
%26 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 0
%27 = load i8*, i8** %3
%28 = call i32 @strlen(i8* %27)
%29 = sub nsw i32 7, %28
%30 = call i32 @memset(i8* %26, i32 48, i32 %29)
%31 = load i8*, i8** %4
%32 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 0
%33 = load i8*, i8** %3
%34 = call i32 @strlen(i8* %33)
%35 = sub nsw i32 7, %34
%36 = call i32 @strncat(i8* %31, i8* %32, i32 %35)
br label %37
37: ; preds = %22, %18
br label %38
38: ; preds = %37, %11
ret i32 0
}

LLVM IR (-O2):
define i32 @padrightzeros(i8* %0, i8* %1) {
%3 = alloca [7 x i8]
%4 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @strlen(i8* %0)
%6 = icmp sgt i32 %5, 7
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = tail call i32 @strncpy(i8* %1, i8* %0, i32 7)
br label %21
9: ; preds = %2
%10 = icmp eq i32 %5, 7
br i1 %10, label %11, label %13
11: ; preds = %9
%12 = tail call i32 @strncpy(i8* %1, i8* %0, i32 7)
br label %21
13: ; preds = %9
%14 = tail call i32 @strcpy(i8* %1, i8* %0)
%15 = tail call i32 @strlen(i8* %0)
%16 = sub nsw i32 7, %15
%17 = call i32 @memset(i8* %4, i32 48, i32 %16)
%18 = call i32 @strlen(i8* %0)
%19 = sub nsw i32 7, %18
%20 = call i32 @strncat(i8* %1, i8* %4, i32 %19)
br label %21
21: ; preds = %11, %13, %7
ret i32 0
}