#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 bi_input(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int setbit(int, int, int, int);
int /*<<< orphan*/ to2(int, char *);
main() {
  char s[20];
  char c[20];
  char d[20];
  int x, y;
  int p, n;
  printf("input x:");
  scanf("%s", s);
  x = bi_input(s);
  printf("input y:");
  scanf("%s", c);
  y = bi_input(c);
  printf("input is %d(%s)\n", x, s);
  printf("input is %d(%s)\n", y, c);
  printf("p=? n=?\n");
  scanf("%d %d", &p, &n);
  printf("The result is %d\n", setbit(x, p, n, y));
  printf("result in binumber:");
  to2(setbit(x, p, n, y), d);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x20(%rbp),%rsi
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1070 <scanf@plt>
lea    -0x20(%rbp),%rdi
call   1030 <bi_input@plt>
mov    %eax,-0x64(%rbp)
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x40(%rbp),%rsi
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1070 <scanf@plt>
lea    -0x40(%rbp),%rdi
call   1030 <bi_input@plt>
mov    %eax,-0x68(%rbp)
mov    -0x64(%rbp),%esi
lea    -0x20(%rbp),%rdx
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x68(%rbp),%esi
lea    -0x40(%rbp),%rdx
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe40(%rip),%rdi
lea    -0x6c(%rbp),%rsi
lea    -0x70(%rbp),%rdx
mov    $0x0,%al
call   1070 <scanf@plt>
mov    -0x64(%rbp),%edi
mov    -0x6c(%rbp),%esi
mov    -0x70(%rbp),%edx
mov    -0x68(%rbp),%ecx
call   1060 <setbit@plt>
mov    %eax,%esi
lea    0xe1d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x64(%rbp),%edi
mov    -0x6c(%rbp),%esi
mov    -0x70(%rbp),%edx
mov    -0x68(%rbp),%ecx
call   1060 <setbit@plt>
mov    %eax,%edi
lea    -0x60(%rbp),%rsi
call   1050 <to2@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x70,%rsp
lea    0xe8d(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe88(%rip),%rbp
lea    0x50(%rsp),%r14
mov    %rbp,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1080 <scanf@plt>
mov    %r14,%rdi
call   1040 <bi_input@plt>
mov    %eax,%r15d
lea    0xe67(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x30(%rsp),%r12
mov    %rbp,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1080 <scanf@plt>
mov    %r12,%rdi
call   1040 <bi_input@plt>
mov    %eax,%ebp
lea    0xe46(%rip),%rbx
mov    %rbx,%rdi
mov    %r15d,%esi
mov    %r14,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r12,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe5d(%rip),%rdi
call   1030 <puts@plt>
lea    0xe25(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
xor    %eax,%eax
call   1080 <scanf@plt>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
mov    %r15d,%edi
mov    %ebp,%ecx
call   1070 <setbit@plt>
lea    0xe01(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe03(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
mov    %r15d,%edi
mov    %ebp,%ecx
call   1070 <setbit@plt>
lea    0x10(%rsp),%rsi
mov    %eax,%edi
call   1060 <to2@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"input x:\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [9 x i8] c"input y:\00"
@.str.3 = [17 x i8] c"input is %d(%s)\0A\00"
@.str.4 = [9 x i8] c"p=? n=?\0A\00"
@.str.5 = [6 x i8] c"%d %d\00"
@.str.6 = [18 x i8] c"The result is %d\0A\00"
@.str.7 = [20 x i8] c"result in binumber:\00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = alloca [20 x i8]
%3 = alloca [20 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%9 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%12 = call i32 @bi_input(i8* %11)
store i32 %12, i32* %4
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%14 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%17 = call i32 @bi_input(i8* %16)
store i32 %17, i32* %5
%18 = load i32, i32* %4
%19 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %18, i8* %19)
%21 = load i32, i32* %5
%22 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %21, i8* %22)
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%25 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32* %6, i32* %7)
%26 = load i32, i32* %4
%27 = load i32, i32* %6
%28 = load i32, i32* %7
%29 = load i32, i32* %5
%30 = call i32 @setbit(i32 %26, i32 %27, i32 %28, i32 %29)
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i32 %30)
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0))
%33 = load i32, i32* %4
%34 = load i32, i32* %6
%35 = load i32, i32* %7
%36 = load i32, i32* %5
%37 = call i32 @setbit(i32 %33, i32 %34, i32 %35, i32 %36)
%38 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%39 = call i32 @to2(i32 %37, i8* %38)
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"input x:\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [9 x i8] c"input y:\00"
@.str.3 = [17 x i8] c"input is %d(%s)\0A\00"
@.str.5 = [6 x i8] c"%d %d\00"
@.str.6 = [18 x i8] c"The result is %d\0A\00"
@.str.7 = [20 x i8] c"result in binumber:\00"
@str = [8 x i8] c"p=? n=?\00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = alloca [20 x i8]
%3 = alloca [20 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%7 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%8 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%9 = bitcast i32* %4 to i8*
%10 = bitcast i32* %5 to i8*
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%13 = call i32 @bi_input(i8* %6)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%16 = call i32 @bi_input(i8* %7)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %13, i8* %6)
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %16, i8* %7)
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
%20 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32* %4, i32* %5)
%21 = load i32, i32* %4
%22 = load i32, i32* %5
%23 = call i32 @setbit(i32 %13, i32 %21, i32 %22, i32 %16)
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i32 %23)
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0))
%26 = load i32, i32* %4
%27 = load i32, i32* %5
%28 = call i32 @setbit(i32 %13, i32 %26, i32 %27, i32 %16)
%29 = call i32 @to2(i32 %28, i8* %8)
ret i32 0
}