#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*/ printf(char *, ...);
int submask_masktoprefix(char *);
int /*<<< orphan*/ submask_prefixtomask(int, char *);
int foo1() {
  char ipbuf[56];
  printf("foo1 submask_masktoprefix mask:%s ===> prefix:%d\n",
         "255.255.255.128", submask_masktoprefix("255.255.255.128"));
  submask_prefixtomask(25, ipbuf);
  printf("foo1 submask_prefixtomask prefix:%d ===> mask:%s\n", 25, ipbuf);
  return 0;
}


x86 assembly (clang, -O0):
<foo1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
lea    0xef3(%rip),%rdi
call   1040 <submask_masktoprefix@plt>
mov    %eax,%edx
lea    0xeb3(%rip),%rdi
lea    0xede(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x40(%rbp),%rsi
mov    $0x19,%edi
call   1050 <submask_prefixtomask@plt>
lea    -0x40(%rbp),%rdx
lea    0xece(%rip),%rdi
mov    $0x19,%esi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<foo1>:
push   %rbx
sub    $0x40,%rsp
lea    0xef6(%rip),%rbx
mov    %rbx,%rdi
call   1040 <submask_masktoprefix@plt>
lea    0xeb5(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rsp,%rbx
mov    $0x19,%edi
mov    %rbx,%rsi
call   1050 <submask_prefixtomask@plt>
lea    0xed4(%rip),%rdi
mov    $0x19,%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [50 x i8] c"foo1 submask_masktoprefix mask:%s ===> prefix:%d\0A\00"
@.str.1 = [16 x i8] c"255.255.255.128\00"
@.str.2 = [50 x i8] c"foo1 submask_prefixtomask prefix:%d ===> mask:%s\0A\00"
define i32 @foo1() {
%1 = alloca [56 x i8]
%2 = call i32 @submask_masktoprefix(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %2)
%4 = getelementptr inbounds [56 x i8], [56 x i8]* %1, i64 0, i64 0
%5 = call i32 @submask_prefixtomask(i32 25, i8* %4)
%6 = getelementptr inbounds [56 x i8], [56 x i8]* %1, i64 0, i64 0
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0), i32 25, i8* %6)
ret i32 0
}

LLVM IR (-O2):
@.str = [50 x i8] c"foo1 submask_masktoprefix mask:%s ===> prefix:%d\0A\00"
@.str.1 = [16 x i8] c"255.255.255.128\00"
@.str.2 = [50 x i8] c"foo1 submask_prefixtomask prefix:%d ===> mask:%s\0A\00"
define i32 @foo1() {
%1 = alloca [56 x i8]
%2 = getelementptr inbounds [56 x i8], [56 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @submask_masktoprefix(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %3)
%5 = call i32 @submask_prefixtomask(i32 25, i8* %2)
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0), i32 25, i8* %2)
ret i32 0
}